0
votes

In my kendo grid I am loading data

.Grid<Portals.Areas.Reports.Models.TransactionReportItem>()  

like this. But again I provided in DataSource

.DataSource(dataSource => dataSource
                          .Ajax()
                          .PageSize(100)
                          .Read(read =>                                    
                           read.Action("GetTransactions","Transactions")))

My problem is when I provided some external filter, because of datasource it is displaying all data instead of filter data. My question is how we can apply external filter condition in data source or is it possible to stop calling datasource? I am using server side grid control.

1

1 Answers

0
votes

On the Read action add this:

.Read(read => read.Action("GetTransactions","Transactions").Data(getDataFilters))

.Data() will call the function you give it every time the Read action occurs.

<scrip>
    function getDataFilters() {
        // Add the values from you filters into variables.
        var filterField1 = $('#filterField1').val();
        var filterField2 = $('#filterField2').val();

        // Set the values of your model
        return {
            ModelFieldName1: filterField1,
            ModelFieldName2: filterField2
        }
    }
</script>

Make sure you have a parameter set in GetTransactions action that will hold this data. I don't know how your controller is set up, but you can see which fields have a filter on them, then set up a Where clause when you grab your data.