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

how to work w/o datasource

4 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Piyush Bhatt
Top achievements
Rank 2
Piyush Bhatt asked on 13 Jan 2012, 10:33 PM
I have tried several methods to get data in the grid (and may be other controls where datasource can be used).

But my overall experience has been that datasource should not be the only option available to show/refres data in the grid and other controls. We should be able to do that via regular functions. For example, if I am able to receive data using any javascript function in the format of Array [object, object, object] then I expect to be able to

> initialize the grid with this data if the grid is not displayed
> refresh the grid with this content if grid has some old data
> insert this data in the grid or append it somewhere in the grid

But I notice most of the examples are with 'datasource' and its either very hard to configure the datasource or I am not savvy enough to do this. 

so if we can work with the kendo objects without using datasource configuration of url/type etc that would be useful. I would like functions such as init(Array) refresh(Array) or something like that if possible.

-Piyush

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 17 Jan 2012, 10:35 AM
Hi,

We generally don't intend to introduce API which will work without the DataSource. The latter is a very important part of Kendo UI and all data access and data operations are performed through it. Inserting records is supported via the insert/add/ methods of the datasource. You can use the data() method to replace all data.

grid.dataSource.data([object, object])

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Naveen
Top achievements
Rank 1
answered on 20 Jan 2012, 07:23 AM
HI all,
iam getting below error,can any one help me to solve this error.iam getting this eoor while connecting data from database through odata services.

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/>
<message xml:lang="en-IN">
The query parameter '$format' begins with a system-reserved '$' character but is not recognized.
</message>
</error>

0
Amol
Top achievements
Rank 1
answered on 24 Jan 2012, 01:19 PM
What about an empty datasource? How to generate one?
0
Gary
Top achievements
Rank 1
answered on 26 Jan 2012, 01:34 AM
If you want to use DataSource.{add, insert} you need to define a schema model on that DataSource. Unfortunately, those methods throw exceptions if you haven't defined a model. If you want to use local Javascript objects, you need to initialize the DataSource data attribute with a new Array or they'll all use the same one (from the initialization options), and then simply manipulate the data Array:

DataSource ds = new kendo.data.DataSource({
  data: []
});

var data = ds.data();
data.push({id: 42});
ds.read(data);
Tags
Grid
Asked by
Piyush Bhatt
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Naveen
Top achievements
Rank 1
Amol
Top achievements
Rank 1
Gary
Top achievements
Rank 1
Share this question
or