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

Adding the originalTR to the record object #230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DotSlashNatalie
Copy link

I made this change in my project because I added a CSS class to certain rows (such as rows to indicate an error). This change allows you to view or access the original tr so that you can copy the CSS class that was applied to it and apply the CSS class to the new tr generation. I'm sure there are better ways to achieve this - but this was my quick patch to get what I needed working.

Example:

function defaultRowWriter(rowIndex, record, columns, cellWriter) {
    var tr = '';


    // grab the record's attribute for each column
    for (var i = 0, len = columns.length; i < len; i++) {
      tr += cellWriter(columns[i], record);
    }

    return '<tr class="' + record.originalTR[0].className + '">' + tr + '</tr>';
  };

@JangoSteve
Copy link
Member

Thanks for submitting this. I like the idea, but this could potentially cause a large balloon in memory usage for tables with a lot of rows. To pull this in, I'd think about only copying the class name if it exists for the row, and only doing so if a config option to copy row classes is enabled (i.e. add a new config option and make it false by default).

@DotSlashNatalie
Copy link
Author

That makes sense. I'll make the modifications in the near future. I've just been handed a big project so I won't be able to make the change for awhile. Feel free to poke this PR if you think I forgot about this.

@DotSlashNatalie
Copy link
Author

Is the latest commit what you were thinking of?

Here is a sample: http://jsfiddle.net/904zebn5/1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants