jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Cell renderer DOM elements not found by jquery
This topic contains 7 replies, has 2 voices, and was last updated by ivailo 9 years, 1 month ago.
-
Author
-
Hi,
I’m using a custom cell renderer as follows:var editlinkrenderer = function (row, columnfield, value, defaulthtml, columnproperties) { defaulthtml = $(defaulthtml).html('<a class="GridEditLink">' + $(defaulthtml).text() + "</a>")[0].outerHTML; return defaulthtml; }
The cell is being rendered as I want it to, great.
The problem I’m facing is that I when I use jquery to find the elements with “GridEditLink” class$('#jqxgrid').find('.GridEditLink') I get 0 elements, while there are 20 rows in the grid. I tried in the grid "ready" property.
$(‘#jqxgrid’).jqxGrid({ ready : function() { var i = $(‘#jqxgrid’).find(‘.GridEditLink’).length; });
No luck either.
How and when can I reach the element, I added within the renderer, by its class name?Hi gush,
We can’t see such a behavior. Please look at this demo.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHi ivailo,
Thank you for your reply.
The only difference I can see between the demo and my code is that in the demo the data is being loaded prior to initializing the grid, whereas my ‘source’ var looks like this:var sourceVar = { datatype: "json", datafields: dataFieldsVar, url: 'server url', root: 'Rows' }; var dataAdapter = new $.jqx.dataAdapter(sourceVar); grid.jqxGrid( { source: dataAdapter, ... });
Do you think this is why I can’t find my link elements?
Should I load the data first, then pass it to the grid?Regards,
Hi gush,
This don’t have to be a reason to different behavior. In both cases the ready callback is executed at the end of the grid’s initialization.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHi ivailo,
Got it. it’s working now.
Thank you.But, I’m getting only the visible rows. Any way I can get all the “.GridEditLink” elements?
Regards,
btw,
The reason I was getting 0 elements in the ready method was because I had “virtualmode” set to true.hi,
here’s how it sums up, and please forgive my not-enough-technical language.I’m using server-side paging; so, in order to have the total number of rows vs. the rows in the current page, and for the grid to display the right number of pages in the pager, I have to set virtualmode to true.
Now, when virtualmode is set to “true”, the following is incorrect:
the ready callback is executed at the end of the grid’s initialization
Not to forget that, even when virtualmode is set to “false”, and
ready : function() { var i = $('#jqxgrid').find('.GridEditLink').length; console.log(i); }
works, it works only for initially visible rows.
Hi gush,
This is a normal behavior.
Please look at this demo how to get total rows number.Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.