Skip to content
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

Merged
merged 1 commit into from
Nov 26, 2013

Conversation

christhomas
Copy link
Contributor

...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.

…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.
@Mottie
Copy link
Owner

Mottie commented Nov 24, 2013

Hi @christhomas!

I'm not sure why this is needed. The ajaxProcessing option is set up to allow returning the following:

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 ];
}

@christhomas
Copy link
Contributor Author

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?

@Mottie
Copy link
Owner

Mottie commented Nov 25, 2013

Hi @christhomas!

This doesn't sound like that bad of an idea... I'll go ahead and merge this with a few minor changes.

@christhomas
Copy link
Contributor Author

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.

@Mottie
Copy link
Owner

Mottie commented Nov 25, 2013

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 :)

@christhomas
Copy link
Contributor Author

ok, then I'll continue with v2 and see how our versions diverge, or ideas come together.

Mottie added a commit that referenced this pull request Nov 26, 2013
I modified the location where the pager creates new <td> elements by fir...
@Mottie Mottie merged commit f40e009 into Mottie:master Nov 26, 2013
Mottie added a commit that referenced this pull request Dec 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants