Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilterForm #134

Open
sebDK opened this issue Dec 11, 2014 · 3 comments
Open

FilterForm #134

sebDK opened this issue Dec 11, 2014 · 3 comments

Comments

@sebDK
Copy link

sebDK commented Dec 11, 2014

Hi there,

First thank you for your work. It is really helpful.

I am using the easygrid plugin with grails 2.3.1 and easygrid:1.6.9.
It is fine, I have no problem to show my list.
Now I would like to add a form on the top of the grid to add a more complex filter like for example "Where author or co author is me"

I m trying this simple code
Here is how my controller is looking like (inspired from #113):

def reportsGrid = {
    domainClass Report
    gridImpl 'jqgrid'
    jqgrid {
    sortname 'started'
    sortorder 'desc'
    }
        enableFilter true
        filterForm {        
            testrevision{
            filterClosure { Filter filter ->
                          applyFilter(delegate, FilterOperatorsEnum.EQ, 'revision', filter.value)
                      }
                  }
            }
    ...
}

Here is the code in my GSP file:

<grid:gridForm name="reports_table">
    <input type="text" name="testrevision"/>
</grid:gridForm>

Here is a picture of the UI;

image

By the way, I got a problem with the tag gridForm (switch simple quote to "). I changed it to:

def gridForm = { attrs, body ->
        if (attrs.id == null) {
            attrs.id = attrs.name
        }
        out << "<form name='${attrs.id}' onsubmit=\""
        if (attrs.function) {
            out << "${attrs.function};"
        }
        out << "return easygrid.filterForm('${attrs.name}',this)"
        out << "\">"
        out << body()
        out << "</form> "
    }

Anyway now when I press enter on my filter input box, the following query is called:
/report/reportsRows?testrevision=7.
Hence the filter data is sent.
But the result is wrong. The grid is just reloaded with the default rowNum 20 instead of the one set in my grid:

<grid:grid name="reports">
   <grid:set width="1900" height="800" rowNum="50" altRows="true"/>
</grid:grid>

I set a breakpoint in FilterService and FilterFormService but it looks like they are never run. It might explain my problem. Any idea?

@sebDK
Copy link
Author

sebDK commented Dec 11, 2014

I think I found why the FilterFormService was not called.
In EasygridDispatchService.groovy

static def services = [
            GridImpl: 'gridImplService',
            DS      : 'dataSourceService',
            AC      : 'autocomplete.autocompleteService',
            Export  : 'export.exportService',
            FFF    : 'filterForm.filterFormService'
    ]

FFF should be FF.

Now FilterFormService is called but without success

@sebDK
Copy link
Author

sebDK commented Dec 15, 2014

Finally, I made it working.
First be sure to change FFF to FF in EasygridDispatchService.groovy
Second, here is the way to add a filter form:

filterForm {
            fields {
                'testauthor' {
                    label 'testlabel'
                    type 'text'
                    filterDataType String
                    filterClosure { Filter filter ->
                        or{
                            eq('username', filter.paramValue)
                            eq('coeditor', filter.paramValue)
                        }
                    }
                }
             }
        }

@tudor-malene
Copy link
Owner

Hi sebDK,
thanks for using easygrid.
I'm glad you made it work eventually.

The filterForm functionality hasn't unfortunately really gone beyond experimental, yet.
I haven't had too much time to work on it.

Thanks for the fixes. I will add them to the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants