Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #104659
    Peter
    Participant

    Hi,

    Which is the best way to switch dataset for a grid?

    I tried to set the grid.dataSource.dataSource = null; and then setting it to a new array of data, but it seem like the old data just stays in the grid regardless.

    #104662
    Markov
    Keymaster

    Hi,

    grid.dataSource.dataSource = null is an incorrect syntax. If you want to change the dataSource, then you need to set the grid.dataSource to a new dataAdapter or a new Array of data.

    Regards,
    Markov

    #104665
    Peter
    Participant

    Well I had a function that did the entire Smart('#grid', class... thing, and I called that when the data changed, but this was where I noticed that the data in the grid, stayed the same even though the data that was being put into the data adapter as data source, was a new set of data.

    So what part of the grid initialization should be redone (if not all) to switch out all the data in the grid, if not the entire Smart('#grid', class... section?

    #104667

    Hi,

    You shouldn’t call Smart(‘#grid’…) again. Just change the dataSource property to an array or a data adapter.
    See the following demo: https://codepen.io/svetoslavjqwidgets/pen/YzOmpoo

    Best Regards,
    Svetoslav Borislavov

    Smart UI Team
    https://www.htmlelements.com/

    #104716
    Peter
    Participant

    That works – I thought that was what I was doing but apparently I was doing something wrong in my previous code.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.