datasource - specify columns?

7 posts, 0 answers
  1. Kevin
    Kevin avatar
    2 posts
    Member since:
    Feb 2013

    Posted 11 Nov 2015 Link to this post

    Hi. Is there a way to specify which fields are shown in the spreadsheet when binding to a datasource?  I tried excluding a field in schema.model.fields but the spreadsheet still displays all the fields as columns.  Also, is there a way to specify the order that the columns appear?
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 13 Nov 2015 Link to this post

    Hello Kevin,

    Currently, this is not possible via the initial configuration. However, it is possible when using setDataSource method of the Sheet. Similar to the following:

    var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");         
     
    var sheet = spreadsheet.activeSheet();
     
    sheet.setDataSource(dataSource, [
      { field: "ProductID", title: "Product ID" },
      { field: "ProductName", title: "Product Name" },
      { field: "UnitPrice", title: "Unit Price" }
    ]);


    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Jeff
    Jeff avatar
    5 posts
    Member since:
    Jan 2011

    Posted 09 May in reply to Rosen Link to this post

    Where would this code be placed on the page as I am having the same issue.

     

    I tried the sheet.RequestEnd which works as you described when the page loads but as soon as I start to try and edit any of the cells in the spreadsheet the page freezes with a long running script error. If I comment out the code and just load the whole table everything works fine

     

    thanks

    Jeff Murtari

  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 10 May Link to this post

    Hello Jeff,

    The code in question should be executed at the point where it is appropriate to set the DataSource instance for your specific scenario. For example if you want to set the DataSource during initial loading you could use a document ready to do so.

    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 10 May Link to this post

    Hello Jeff,

    Just to add about the approach you have tried. You should not use requestEnd to change the DataSource instance as this could result in an endless loop,. which I suspect is the behavior you are experiencing.

    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  7. Jeff
    Jeff avatar
    5 posts
    Member since:
    Jan 2011

    Posted 10 May in reply to Rosen Link to this post

    Rosen thanks for the quick reply. Would you have a quick example as I am having some issues with the document ready.

    I have the datasource set in the sheet .Read command but am trying to limit the columns displayed. The trouble I seem to be having with the documentready is that the datasource is set at the .Sheet level and not the spreadsheet control level

     

    thanks

    jeff

     

  8. Jeff
    Jeff avatar
    5 posts
    Member since:
    Jan 2011

    Posted 10 May in reply to Jeff Link to this post

    Rosen I have gotten the document ready script to work so thank you for pointing me in the right direction. Now just having an issue when I try to update a date field in the spreadsheet but will open another ticket

     

    thanks again

Back to Top
Kendo UI is VS 2017 Ready