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

Update datasource?

3 Answers 520 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 02 Apr 2012, 08:37 PM
I have a datasource/grid that I would like to update depending on selected in a TreeView.

I have my datasource created like so:

        dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "/api/items",
                    dataType: "json",
                    data: { id: "1" }
                }
            }
        });

When a user selected an item on the TreeView I want to update the datasource to change the id that defines its results. Can I just create a new dataSource with the new {data: {id: "newid"}}?

How would I then apply this to the grid that already exists?

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 04 Apr 2012, 11:51 AM
Hi Kyle,

You may change a parameters defined through the transport's operation data by assigning a function which to return the updated value. Please refer to this online demo for more details. Note the q parameter's definition.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Juan
Top achievements
Rank 1
answered on 10 Apr 2012, 07:01 PM
Thanks you, is work fine in my code.
0
Muhammad
Top achievements
Rank 1
answered on 08 Nov 2012, 08:33 AM
is working in the "update" add this code in the transport:
               complete: function(e) {
$("#grid").data("kendoGrid").dataSource.read(); 
}


thanks a lot
Tags
Data Source
Asked by
Kyle
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Juan
Top achievements
Rank 1
Muhammad
Top achievements
Rank 1
Share this question
or