Gridx / Dojo & jQuery: is there a callback when sorting is complete?

enter image description here

This table is created using GridX / dojo in NodeWebkit. "[BV] [B] [V]" are links that are processed by jQuery using the class selector. However, once I sort the grid, no listeners are attached. How do I reapply the click feature? Is there a callback when sorting and rendering is complete?

+3


source to share


3 answers


There is no callback or event I know when the sort is complete in gridx.

However, the entire mesh is re-rendered when it is sorted or filtered. Therefore, you can use something like:



grid.connect(grid.body, 'onRender', function(){
    $(document).on("click", "a.myBVlink", function() {
      ...
    });
    $(document).on("click", "a.myBlink", function() {
      ...
    });
    $(document).on("click", "a.myVlink", function() {
      ...
    });
});

      

+3


source


I created a wrapper wrapper and added a click listener to it as -

$('#gridWrapper').on('click','.myLinkClass',function(){
    console.log('clicked');
    console.log(this);
});

      



gridWrapper

does not change. This way, the listener remains active and the selector .myLinkClass

selects <a href="#" class="myLinkClass">text</a>

despite the sorting.

0


source


Like @mccannf I am using re-render event. To prevent duplicate work, I just use the counting variable and only do the work a second time.
Note: If the grid is empty at the start, I set the counter to 1 because the event is only fired once.

var countRender = 0;
if (grid.store.data.length == 0) countRender=1; 

grid.connect(grid.body, 'onRender', function(gridName){
    if (!countRender++) return;
    countRender=0;
    ...
});

      

0


source







All Articles