Wiki

Clone wiki

grails-datatables / sqlRestrictionFunction

sqlRestrictionFunction

Values

Name Type Default
sqlRestrictionFunction String none

Description

sqlRestrictionFunction is a table option that allows you to specify a JavaScript function that will return a sqlRestriction criterion string that will filter the results dynamically. This is useful if you wish to have additional search controls on your page, such as a range selector. The function you specify will be called prior to each table refresh. For example, if your function returns "char_length(first_name) = 4", your table will be filtered to only display items having a firstName with 4 letters. See here for more information about the sqlRestriction criterion.

Note that you can also edit all the data sent to the server on each AJAX request by using the jQuery DataTables ajax.data option.

Example

<dt:datatable name="MyTable" domainClass="this.is.my.DomainClass" serverSide="true" sqlRestrictionFunction="getRestriction">
    <dt:column name="firstName"/>
    <dt:column name="mySecondProperty"/>
</dt:datatable>

<script type="JavaScript">
    function getRestriction() {
        var nameLength
        // ...
        return "char_length(first_name) = " + nameLength;
    }
</script>

See Also

criteria


Back to Options.

Updated