PDA

View Full Version : Sorting removes specified events



mjohnsonaz74
16 Mar 2011, 7:44 AM
I have a datagrid with some custom renderers:


function renderShowViews(value, p, record) {
return value ? String.format('<a class="viewed" href="/showViewed/{0}">{1}</a>', record.data.eventId, value) : value;
}

function renderPassed(value, p, record) {
return value ? String.format('<a class="passed" href="/viewPasses/{0}">{1}</a>', record.data.eventId, value) : value;

}

function renderIndications(value, p, record) {
return value ? String.format('<a class="indications" href="/viewIndications/{0}?product={1}">{2}</a>', record.data.id, record.data.product, value) : value;

}

On the data store I have the following listeners:


listeners: {
load: function(store, records, options) {
$(".viewed").colorbox();
$(".passed").colorbox({width:"75%",opacity:"0.7"});
$(".indications").colorbox({width:"75%",opacity:"0.7"});
},
datachanged: function(store) {
$(".viewed").colorbox();
$(".passed").colorbox({width:"75%",opacity:"0.7"});
$(".indications").colorbox({width:"75%",opacity:"0.7"});
}
},

The 'load' listeners work as expected. However, after I click on a column header to sort, the events are no longer in place (presumably because the rows have been re-rendered, thus erasing the previous events). I then implemented the 'datachanged' listener to re-assign my events after a sort. However, the events shown are not being attached to their specified element. I added an alert message (not shown) to the datachanged event to make sure that it was firing and it was. So, what appears to be happening is that the datachanged event is firing after I click to sort the column, but before the rows are fully rendered. Is there a better way to attach my events to a custom rendered column?

Thanks,

-MJ

mjohnsonaz74
17 Mar 2011, 12:40 PM
Does anybody have any ideas? I've seen a 'Sort' event listed in the past, but that seems to have been replaced with 'datachanged'. Is there a post sort event that I can use to reattach events to my DOM objects? The 'datachanged' event seems to be firing too early. Is there an event that fires after 'datachanged' either as part of the Store or even the GridPanel? Any thoughts would be appreciated.

-MJ