Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #100275
    admin
    Keymaster

    I have a data adapter for Grid.
    I can add to end with e.g.:
    document.addCourseGrid.dataSource.add({id:’mytest’, code:’f123aacdee’});
    I can insert somewhere in the rows e.g.
    document.addCourseGrid.dataSource.insert(1, {id:'mytest', code:'f123aacdee'});
    This will insert in the second position.
    But I cannot insert at the top:
    document.addCourseGrid.dataSource.insert(0, {id:'mytest', code:'f123aacdee'});
    `
    smart.grid.row.js:282 Uncaught TypeError: Cannot set property ‘row’ of undefined
    at Row.render (smart.grid.row.js:282)
    at HTMLElement._renderFrozenRows (smart.grid.core.js:6944)
    at HTMLElement._recycle (smart.grid.core.js:6914)
    at DataAdapter.notifyFn (smart.grid.core.js:4535)
    at DataAdapter._notify (smart.data.js:193)
    at DataAdapter.insert (smart.data.js:634)
    at <anonymous>:1:35
    `

    #100276
    admin
    Keymaster

    Ugh, sorry about that. The impossible forum software again.

    smart.grid.row.js:282 Uncaught TypeError: Cannot set property 'row' of undefined
    at Row.render (smart.grid.row.js:282)
    at HTMLElement._renderFrozenRows (smart.grid.core.js:6944)
    at HTMLElement._recycle (smart.grid.core.js:6914)
    at DataAdapter.notifyFn (smart.grid.core.js:4535)
    at DataAdapter._notify (smart.data.js:193)
    at DataAdapter.insert (smart.data.js:634)
    at <anonymous>:1:35
    #100279
    admin
    Keymaster

    Sorry, I can’t find how to delete a post, I have to leave the duplicate above.
    I looked at source code, and I find nothing that seems to prepend. Only add() and insert().

    #100281
    admin
    Keymaster

    Based on: https://www.htmlelements.com/demos/grid/dynamic-rows/.
    Use rows.splice(0, 0, createRow()); in the example, within the addRow click handler.
    Regards,
    George
    Smart Html Elements Team
    https://www.htmlelements.com/

    #100282
    admin
    Keymaster

    I would prefer to work with the bound data, though.
    I’m afraid I am thoroughly confused about adding rows by creating a row and adding nodes to the grid, vs. adding rows to the data source.
    The latter is my preference, and it does work, but only for append and insert but not insert at top.
    I had hoped I could manipulate the data source, as it is most convenient for e.g. update an array from a REST fetch, but only having partial luck with this. Works if I want to add to the end or middle, just not at the top.

    #100284
    admin
    Keymaster

    The problem was that I had the first row frozen. It will get an exception as shown above if you try to insert before a frozen row.
    If not frozen, then I can insert at 0, and it works. This gives me the most-recent-first insertion I want to show history.
    I can see that it’s not obvious what the “correct” behaviour might be. It depends on the full definition of what you consider to be “frozen”.
    I think anyway I didn’t need to freeze, as I just want to freeze the headers. I supposed the headers are automatically frozen anyway.

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