【问题标题】:Kendoui Grid send dynamic variable in data sourceKendoui Grid在数据源中发送动态变量
【发布时间】:2014-04-16 08:52:51
【问题描述】:

我正在尝试根据从选择下拉列表中选择的选项“过滤”网格。

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

我的网格数据源是:

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
                }
            }
        }
    }
})

我的选择事件:

$('#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();
            }
        })

【问题讨论】:

    标签: javascript jquery kendo-ui kendo-grid kendo-datasource


    【解决方案1】:

    我无法确认。但是由于您在 dataSourceParts 中设置了过滤器。你不应该使用dataSourceParts.read() 而不是$('#shippingPartsGrid').data('kendoGrid').dataSource.read(); 吗?

    【讨论】:

      【解决方案2】:
      $('#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
                      });
                  }
              })
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-11
        • 1970-01-01
        • 2022-01-13
        • 2017-09-26
        相关资源
        最近更新 更多