jQWidgets Forums

jQuery UI Widgets Forums Grid Changing id field – different rowid in updaterow and deleterow

This topic contains 9 replies, has 4 voices, and was last updated by  adrian_hd 7 years, 9 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author

  • Klaus H
    Participant

    Hi,

    I am having the following behaviour:

    – When I add a row to the grid, I do not directly synchronize the the change to my database via the addrow method of my source, because the user has to insert some mandatory fields in the grid first. I use a negative number as placeholder for the id column

    – When the user changes data in a row and the updaterow is triggered I check if all mandatory fields are entered and if that’s the case, I send a request to my server, the server sends me a response containing an error message or the new id.

    – On getting the new id, i use the setcellvalue method to update the rowdata. Now, when I change the rowdata again after the id has been set and submit the new data to the server I get the correct rowid in the updaterow method and the correct rowid in my id field in the rowdata and the uid in rowdata (that’s the internal id you use I guess).

    So far, so good.

    – Now when I want to delete the newly added row, the deleterow method parameter rowid is still giving me the old placeholder id (the negative number). I don’t understand why that’s the case. I can access the row and it’s data via getselectedrowindex and getrowdata methods. There again everything is fine, so I would use this way to be sure, but maybe you would want to look into that.

    I am aware that this is not 100% the intended behaviour of the grid, though. 😉

    Kind Regards
    Klaus


    Klaus H
    Participant

    Addition:
    My workaround doesn’t work, the getrowdata object has the correct id in it according to my console.log representation of the rowdata. But when I store the id column in a new variable, it also gets the old negative value (var myid = myrowdata.myid). I have tested this behaviour in two browsers.

    I don’t know why, but now that solution works again, however the rowid in the deleterow call still has the old negative id.


    Peter Stoev
    Keymaster

    Hi,

    As far as I know, the uid parameter of jqxGrid i.e the result of the getrowid cannot be changed via the ‘updaterow” or “setcellvalue” methods. That parameter depends on the source object’s ‘id’ parameter or when it is not set is auto-generated by jqxGrid.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    Klaus H
    Participant

    Hello Peter,

    I succeeded in changing the uid for testing purposes with getrowdata and that mydata.uid, but that did not change the behaviour.

    The rowid in the updaterow call is my id with uid beeing the identical value as my id colum and with uid beeing -1.

    The rowid in the deleterow call is always -1 no matter what value is in uid according to the object given to me by getrowdata.

    I seem to have a workaround now (with no idea why it didn’t work the first time I tried – see me edit above), so it’s not a big deal, but it is weird nonetheless.

    Kind Regards
    Klaus


    Peter Stoev
    Keymaster

    Hi Klaus,

    The “uid” is not supposed to be changed at all. That unique id is handled by the Grid internally.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    Klaus H
    Participant

    Hello Peter,

    no problem, I was just curious if that was where the deleterow parameter -1 came from, but that was not the case. 😉

    I had a second (almost similar) grid and the behaviour was the same, but the workaround also works there.

    Kind Regards
    Klaus


    SS
    Member

    Hello all

    Firstly I’m failry new to jqwidgets. I must say these widgets are awesome 🙂
    I know this post is a few months old but I just wanted to add an observation.

    I’ve been trying out the jqxgrid in the same way as Klaus and ran into the same problem as he described. I noticed that when the rowindex and uid are different then the widget has some problems deleting. If one reloads the grid like so, “$(“#jqxGrid”).jqxGrid(‘updatebounddata’);” after a deletion then the index and uid become in sync again. And then the widget doesn’t have a problem deleting a row. It may not be optimal to do this after every delete for large data sets but for now this solves my problem.

    btw I’m using ver2.9.3. I’m not sure if this was solved in the latest version.

    Kind Regards,
    SS


    Peter Stoev
    Keymaster

    Hi SS,

    I would like to ask you to report things that are actual and not for such old versions. Deleting a row should be by ROW ID and it is not necessary the row ID to be the same as the row’s Index. Actually, that is a too specific case when both of these are equal.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    adrian_hd
    Participant

    Hi Klaus H, Have any example of cambiaste id of the row?


    adrian_hd
    Participant

    Hi Klaus H, Have any example of cambiaste id of the row?

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.