Assigning Cell Values From an Array Based on Cell Values
Assigning Cell Values From an Array Based on Cell Values
Hi All,
I've got a tricky piece I'm now trying to do with this table:
http://live.datatables.net/yohuluco/12/edit
Currently, the table will auto-assign the "Total" points based on the individual cell point values. The next iteration I'm trying to do, is auto-assign those individual cell points, based on times (per class) from the related column. So for example, I'd remove the individual values of points in a column and instead reference something like this:
Point Array:
{ 60, 50, 45, 40, 35, 30, etc.. }
And loop through each column of time values, which would look like this:
Time (Segment X for Men's Open, for example):
1. 21:00
2. 21:30
3. 22:34
4. 23:34
5. etc..
So first place (21:00) would get 60 points, second place (21:30) would be 50 points, and so on. Those would be broken up by the three classes (Men Open, Men Sport, Women Open).
I realize this may fall out of the range of what DataTables technically does, but it would go a long way in automating the data entry here.
Thank you,
Ed
Answers
Its hard to say specifically what to do in order to determine the place based on the class( Men Open, Men Sport, Women Open). This could be done in your server script or in the client. The exact process for this is dependent on your data structure and source. This is something I would try to do in the server script if possible. You might be able to create a SQL type query (assuming that is what you have) to group by the class and order each group by timestamp.
If you are using
ajax
you can useajax.dataSrc
as a function to preprocess the data before applying to the table.If its DOM sourced you can use
drawCallback
, if the data can change, orinitComplete
to update the table data. You can userows().every()
to iterate all the rows if appropriate or use other Javascript methods to process the data.Kevin
Thanks Kevin. For reference, I'm just using a text file, with data looking like this for each rider.