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

Datasource Field

2 Answers 185 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 21 Jul 2017, 08:38 PM

Hi, 

I have a dataSource with a number of fields. Is there any way to get the list of these fields, in the order specified when the datasource was created.

I know I can get the list by using dataSource.options.schema.model.fields, however the order in alphabetical and not in the order I used when I created the datasource.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 25 Jul 2017, 08:02 AM
Hello Marc,

Currently, the desired result can be achieved if the model is set using an object variable. Then that variable can be used as a list with all of the model fields in their initial state, as the variable will not be ordered alphabetically.

For example:

var fields = {
    OrderID: { type: "number" },
    Freight: { type: "number" },
    ShipName: { type: "string" },
    OrderDate: { type: "date" },
    ShipCity: { type: "string" }
}
 
......
 
  schema: {
   model: {
    fields:fields
   }
  }

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Marc
Top achievements
Rank 1
answered on 26 Jul 2017, 07:51 AM

Hi Stefan,

Yes this is the way I had planned to do it, but wasn't sure if there was a better way, thanks!

Mard

Tags
Data Source
Asked by
Marc
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Marc
Top achievements
Rank 1
Share this question
or