Datasource Field

3 posts, 0 answers
  1. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 21 Jul Link to this post

    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. Stefan
    Admin
    Stefan avatar
    1143 posts

    Posted 25 Jul Link to this post

    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 visualization (charts) and form elements.
  3. Marc
    Marc avatar
    161 posts
    Member since:
    Sep 2016

    Posted 26 Jul in reply to Stefan Link to this post

    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

Back to Top