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

[Solved] Is it possible to change how data is recieved on runtime?

3 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Can
Top achievements
Rank 1
Can asked on 27 Nov 2014, 01:44 PM
I want to do something like this:

function myRefresh(grd)
{
   if(somecondition)
   {
       grd.datasource.transport = {
            read: { someArguments }
            }
        }
      
        grd.dataSource.read();
   }
   else
   {
       grd.dataSource.transport = undefined;
       grd.dataSource.data(somedata);
   }
}


Based on a condition I want to change how grid reads data. myRefresh(grd) may run anytime during runtime.

But as datasource is changed from static data to transport I get "t.transport.read is not a function" error which is proabaly because datasource.transport was not initially defined.

Do I have to recreate the grid? Or is there a shorter way?

3 Answers, 1 is accepted

Sort by
0
Can
Top achievements
Rank 1
answered on 27 Nov 2014, 03:14 PM
I solved the issue using two grids and showing/hiding them when required.

But I am still curious about the possibility of the above requirement.
0
Kiril Nikolov
Telerik team
answered on 01 Dec 2014, 07:59 AM
Hello Can,

The transport.read.url option can accept a function, so you can pass a function that will resolve the url based on your external requirements. The same is explained here:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read.url

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Kiril Nikolov
Telerik team
answered on 01 Dec 2014, 07:59 AM
Hello Can,


The transport.read.url option can accept a function, so you can pass a function that will resolve the url based on your external requirements. The same is explained here:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read.url


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