Problem with client-side event sequence

Problem with client-side event sequence

TomBajzekTomBajzek Posts: 163Questions: 36Answers: 1

I'm having a problem in attempting to change the way an editor is invoked. The existing app is completely normal in that you invoke the editor on a table by (single) selecting a row and clicking the Edit button. I've augmented this by displaying, in the footer of the editor panel, the contents of records in another table which are related to the selected row. This works fine.

Responding to a client request, I want to be able to invoke the editor by clicking on a designated field in the displayed row, essentially eliminating one click in the process of invoking the editor. I've accomplished that by putting a jquery click handler on the field that invokes the editor. Invoking the editor in this manner works correctly, but there is a problem later in the process.

The problem is with the records displayed from the related table. Since I made this change, the related records are those related to the previously selected row, not the currently selected row. It appears that the editor (and related records) are loaded before the select event is completed. I've verified that clicking the designated field in the row does select the row both by seeing the row being highlighted and by a breakpoint in the select handler.

To debug this, I've set some breakpoints and discovered that the open event for editor caused by the click on the designated field occurs before the select event that is generating by the click (which is in the row). Since the related records have not yet been loaded, the display of related records contains those belonging to the previously selected row.

To confirm this theory, I clicked a row to select it, and then clicked the designated cell that invokes the editor, the result is that I get the correct related data loaded, just as if I had clicked the Edit button. This confirms that the related data from the previously selected row is being fetched rather than the related data for the row that is currently being selected.

I don't know how to proceed. Are these events being generated in the wrong order? Is there some other event that I could use to sequence things correctly? Do I need to abandon this approach?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin
    Answer ✓

    Sounds like you need to use the click to open Editor event to also select the related records (not await for the select event).

    What you describe for the event ordering is what I would expect since the events bubble up the document - the click in the cell will happen before the row and table events.

    Allan

  • TomBajzekTomBajzek Posts: 163Questions: 36Answers: 1

    Allan,

    That clarifies the event sequence. I'll have to see if I know the required data when the select event occurs. When you click the Edit button on a selected row, the data is already in place, because of the way the select-edit sequence works. It looks like I'll have to figure out how to do that in my own code now.

    This clarifies my task.

    Thanks,
    Tom

This discussion has been closed.