-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I modified the location where the pager creates new <td> elements by fir... #434
Conversation
…first asking whether the data contains a td element and if it does, use that instead, this allows the ajax callback to output a fully rendered table with td elements already created, the callback to obtain those elements and just rebuild the columns using those elements, with all the required classnames, attributes, etc.
Hi @christhomas! I'm not sure why this is needed. The Array of arrays: ajaxProcessing: function(data){
/* process data
rows = array of arrays
[
[ "row1cell1", "row1cell2", ... "row1cellN" ],
[ "row2cell1", "row2cell2", ... "row2cellN" ],
...
[ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
]
*/
return [ total, rows, headers ];
} jQuery Object ajaxProcessing: function(data){
/* process data
rows = string
'<tr><td class="special">x</td><td>1</td></tr>'
*/
return [ total, $(rows), headers ];
} or just the total rows; headers is always optional ajaxProcessing: function(data, table){
/* process data
rows = string
'<tr><td class="special">x</td><td>1</td></tr>'
*/
table.config.$tbodies.eq(0).html(rows);
return [ total ];
} |
ah, in the case of the jquery object, you could in fact create each cell and apply all the styles you wanted, I didn't realise that code path was available. but if you don't use the jquery object, this will allow the same functionality, cloning of the exact html you want when rebuilding from the array. the reason is that when you rebuild from an array, you manually create the "[td]" elements yourself, this means I lose all my class names and attributes obviously if you're using jquery objects, this problem goes away, but I think now I've balanced both functionalities so they can ultimately do the same thing or perhaps you can show me where I made my mistake, I read through and this seemed like what I needed to do, perhaps you know a better way? |
Hi @christhomas! This doesn't sound like that bad of an idea... I'll go ahead and merge this with a few minor changes. |
thanks! :) I'm also interested in other aspects of the code, so perhaps I get hacking on other parts, version 3, it's in the github? is it usable? should I hack on that version of continue with v2 because v3 isn't usable yet? What would you recommend? the modification works very nicely actually, I generate the html on the server using the same method I use to generate the html when rendering the page, so my "render path" is identical, then I return each row in the ajax result, then I process each row using jquery, it's super simple and means that my rendered row after tablesorter has finished working with it is exactly the same as it would be if my website rendered it itself. |
I've been too busy to update version 3, which I only have locally, with all the latest changes/fixes. So it's really not usable yet. The function groups are essentially the same, I just have everything reorganized into modules. I still need to make it work with grunt, make it user customizable, rewrite all the docs, etc... a lot of work still left to do. I do appreciate the help with coding :) |
ok, then I'll continue with v2 and see how our versions diverge, or ideas come together. |
I modified the location where the pager creates new <td> elements by fir...
...st asking whether the data contains a td element and if it does, use that instead, this allows the ajax callback to output a fully rendered table with td elements already created, the callback to obtain those elements and just rebuild the columns using those elements, with all the required classnames, attributes, etc.