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

Two Grid in one page, Please help.

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Iron
Vincent asked on 25 May 2018, 01:52 AM

I have Two Grid in one razor page.

<kendo-grid name="DgMaster"  selectable="true">
        <datasource type="DataSourceTagHelperType.WebApi">
            <transport>
                <read url="@Url.Content("~/api/Master")"/>
            </transport>
        </datasource>
    </kendo-grid>

<kendo-grid name="DgDetail">
        <datasource type="DataSourceTagHelperType.WebApi">
            <transport>
                <read url="@Url.Content("~/api/Detail/001")"/>
            </transport>
        </datasource>
    </kendo-grid>

 

I want when Master grid Row select changed, the detail grid datasource change.  <read url="@Url.Content("~/api/Detail/001")"/>  replace "001" to mater grid row data id.

I can get mater grid selected row data in javascript, the code as follow:

function DgMasterChange(e) {
        var grid= $("#DgCategory").data("kendoGrid");
        var row = grid.select();
        var category = grid.dataItem(row);

}

 

I am trying to setDatasource in javascript. but setDatasource method doesn't work.

Please Help.

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 29 May 2018, 06:02 AM
Hello, Vincent,

Thank you for the details.

Indeed, the recommended approach is to change the second Grid dataSource on the master Grid change event.

I noticed that the on the change event the "DgCategory" Grid is accessed, but based on the code it could be the "DgMaster" Grid.

function DgMasterChange(e) {
        var grid= $("#DgMaster").data("kendoGrid");
        var detailGrid = $("#DgDetail").data("kendoGrid");
        var row = grid.select();
        var category = grid.dataItem(row);
        // Create the dataSource with the read value based on the data item.
        detailGrid.setDataSource(theNewDataSource)
}

If this causing any issues, please advise the exact error, or send us a runnable example and I will gladly provide a suggestion best suited for it.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Vincent
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
Share this question
or