This is a migrated thread and some comments may be shown as answers.

Grid datasource rebind on treeview onSelect

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 20 May 2013, 08:03 AM
Hi,
Currently I have a treeview control and a grid control.
I added a onSelect javascript, when treeview is selected, the grid control will be re-bind.
but I don't know how to pass the parameter to Grid control.

function onSelect(e)
{
var grid = $("#Grid").data("kendoGrid");
grid.dataSource.read()
}

.Read(read => read.Action("GetGridData","Home"))

public ActionResult GetGridData(string treeviewItem, [DataSourceRequest]DataSourceRequest request)
{
}
Can you advise how should I pass the parameter to Grid so the grid can call to controller to return data?

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 20 May 2013, 02:00 PM
Hi Dan,


You could use the Data function of the Grid's dataSource Action builder to specify a JavaScript function, that will return additional data for the controller. Here is a sample implementation for the current scenario.
E.g.
.DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("Products_Read", "Grid").Data("additionalData"))
)

var treeItem;
 
function additionalData() {
    return { treeViewItem: treeItem }
}
 
function onSelect(e) {
    treeItem = this.dataItem(e.node).Name;
    var grid = $("#Grid").data("kendoGrid");
    grid.dataSource.read();
}

Please let me know if this was the information that you were looking for.

 

All the best,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or