adding attributes to the cells created by Editor

adding attributes to the cells created by Editor

WIDNR-TinbergWIDNR-Tinberg Posts: 7Questions: 4Answers: 0

I'm still doing the trial of Editor. The Datatable I'm using is sourced with HTML/DOM data. After using the Editor to create a new row in the table I need to apply some data-order attributes to some of the <td> elements as well as add some CSS classes to them. Two questions: 1) Which is the best Editor event to use to do this (is it create or postCreate or something else)? 2) How do I go about accessing the added row using jQuery and add attributes to some of the <td>s in the newly created row?

Thanks,

Brian

Answers

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin

    Hi Brian,

    Where are you getting the data that you want to use for the data-order? Is it a form input, or is it being generated by the server? Its unlikely you want to actually set these attributes directly in DataTables - orthogonal data can provide ways to do it, but I'd need to know a bit more about the structure of your data.

    rowCallback is the best way to handle classes for a row where the data might dynamically change (i.e. the user changes a value that means a class no longer applies).

    Allan

  • WIDNR-TinbergWIDNR-Tinberg Posts: 7Questions: 4Answers: 0

    Ideally, the data would come from the server, but I'm not sure how to provide that in the JSON response so it could become part of the data-order attribute. The data-order just a reformatting of the date values that appear in the table cells, so that they sort correctly. Please see my more recent question which contains examples of the table and the javascript I'm using. thanks.

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin

    How are you populating the table initially? Are you building it as HTML? Can you give me a link to the page please?

    Allan

This discussion has been closed.