Author Topic: Problem with setting dataModel.data after grid initialization  (Read 3348 times)

genk_pqgrid

  • Newbie
  • *
  • Posts: 9
    • View Profile
Hello
My grid is a part of a jq Dialog popup which is shown on top of another grid - main page.
In the popup I basically show detailed info for the current line of the main page. using UPD/DOWn buttons I move between rows and show detailed data. All works fine if I don't modify fields on the detail grid in popup.
If I do modify any field:
- I must copy the values into the model of the main grid and then move to next record
- Then I use values from the next record to build data for the popup
- I'm using this line to set the data for my grid:
        $("#grid_array_pe_text").pqGrid("option", "dataModel.data", m_TextGridData);
- The object m_TextGridData is built from the new current row of the main grid's data.
The problem:
- after execution of the above line instead of filling the grid with data from the object - the object is filled from data. The result is as if the changes from one detail screen are propagated to the next.

Sorry for the long explanation, I spent already a few hours on it and cannot figure it out.
Any help would be greatly appreciated.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Problem with setting dataModel.data after grid initialization
« Reply #1 on: July 30, 2015, 01:15:52 am »
Any chance that you could share a jsfiddle so that I can have a look.

http://jsfiddle.net/7jnf6s3t/104/

genk_pqgrid

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Problem with setting dataModel.data after grid initialization
« Reply #2 on: July 30, 2015, 01:30:34 am »
This is a part of a very large project, so hard to share.
However I at least found the reason and workaround:
- it's caused by "saveEditCell" method.
- when I'm editing a field in the grid and I click on UP/DOWN button the button event fires before any event for the grid row, including the "quiteditcell" event.
- so if I simply follow UP/DOWN processing logic, my cell remains in "limbo" and editing is unfinished.
- so I tried to intercept this with the following piece of code:
    if ($("#" + pGridId).pqGrid("getEditCell") != null) {
        $("#" + pGridId).pqGrid("saveEditCell");
    }
- this actually works - but still leaves the cell in some weird state that makes the data setter to work backwards.
- as soon as I commented this code everything works OK.
- of course I still have the problem of unfinished editing - so I have to ask the user to use TAB or click outside the cell to complete cell editing before using UP/DOWN or close buttons.

Any comments on this would be welcome  :)




force