0

I am trying to "filter" a grid based on an option selected from a select drop down.

How do I send the selected option value to the grid when the change event on the select dropdown fires?

My grid datasource is:

dataSourceParts = new kendo.data.DataSource({
    serverPaging: false,
    serverFiltering: false,
    serverSorting: false,
    transport: {
        read: {
            url: ROOT + 'shipment/partsSerialGrid',
            dataType: 'json',
            type: 'POST',
            data: {
                enquiryId: enquiryId
            }
        }
    },
    pageSize: 25,
    error: function(e) {
        alert(e.errorThrown + "\n" + e.status + "\n" + e.xhr.responseText);
    },
    schema: {
        data: "data",
        total: "rowcount",
        model: {
            id: 'id',
            fields: {
                quantity: {
                    type: 'number',
                    editable: false
                },
                idealForm: {
                    type: 'string',
                    editable: false
                },
                serial: {
                    type: 'string',
                    editable: true
                }
            }
        }
    }
})

My select event:

$('#fromNameSelect').change(function() {
            var fromMode = $('#fromSelect').val();
            if (fromMode == 2)
            {
                supplierId = $(this).val();
                dataSourceParts.filter({
                    field: 'test', operator: 'eq', value: 'test' // THIS DOES NOTHING.
                });
                $('#shippingPartsGrid').data('kendoGrid').dataSource.read();
            }
        })
imperium2335
  • 23,402
  • 38
  • 111
  • 190

2 Answers2

0

I cant confirm this. But since you set filter in dataSourceParts. Shouldn't you be using dataSourceParts.read() instead of $('#shippingPartsGrid').data('kendoGrid').dataSource.read();?

YS.Tan
  • 511
  • 3
  • 6
0
$('#fromNameSelect').change(function() {
            var fromMode = $('#fromSelect').val();
            if (fromMode == 2)
            {
                supplierId = $(this).val();
                 $('#shippingPartsGrid').data('kendoGrid').dataSource.filter({
                    field: 'test', operator: 'eq', value: 'test' // DO IT LIKE THIS
                });
            }
        })