How to use SetDataSource Method of the Kendo UI Grid

后端 未结 2 1050
萌比男神i
萌比男神i 2021-01-02 08:35

Has anyone been able to use setdatasource method of the kendo UI grid? I believe this is used to assign datasource that can be assigned to the grid at the later stage and al

2条回答
  •  滥情空心
    2021-01-02 08:56

    What have you tried so far? This is pretty basic.

    Example:

    var ddl = $('#testDropDown').data("kendoDropDownList");
    var otherDropDownList= $('#otherDropDown').data("kendoDropDownList");
    
    var ds = new kendo.data.DataSource();
    ds.data(otherDropDownList.dataSource.data()); // set new DataSource to otherDropDown's data source then filter it
    ds.filter(
         {
             field: "Id",
             operator: "eq",
             value: parseInt(id)
         }
    )
    
    ddl.setDataSource(ds);
    

    Obviously this is all going to be different for whichever scenario you have.

    Update for Grid

    var ds = new kendo.data.DataSource();
    var grid = $('#grid').data("kendoGrid");
    
    grid.setDataSource(ds); // sets to a blank dataSource
    

    Or, use this dataSource with another grid?

    var gridDataSource = $('#grid').data("kendoGrid").dataSource;
    var secondGrid = $('#secondGrid').data("kendoGrid");
    
    secondGrid.setDataSource(gridDataSource);
    

提交回复
热议问题