DataTables sticky row and custom data

DataTables sticky row and custom data

marcellomarcello Posts: 8Questions: 1Answers: 0
edited August 2016 in Free community support

I'm trying to get my table to always display a specific row as the first child, even when sorting or changing pages.

I got it to work with the sorting (its using an ID column to fix it) but when I change pages, the first row goes away.

I tried using fnDrawCallBack but can't get it to work properly.

Another thing I need is to get that Fixed row to be specific according to a selector.

It works fine for 1-2 options, but my table will have over 90 options to select from, and doing "ifs" for all of those will just be a lot of code... is there a simpler way?

Here is a fiddle: http://jsfiddle.net/3ee390r4/8/

Answers

  • marcellomarcello Posts: 8Questions: 1Answers: 0
    edited August 2016

    Ok, I got somewhere :)

    I've updated the fiddle, but I need a better way of displaying that top row if the selector has 90 options.

    I'd like this to be cleaner for all possible selections:

    $("#table_id > tbody tr:first").before("<tr><td>"+ dataB[0]+"</td><td>"+ dataB[1]+"</td><td>"+ dataB[2]+"</td></tr>");

    is there a way of adding that row with the tables correct formatting without doing all those <tr><td>"+ dataB[0]+"</td><td> for every value on the data?

    I'll be using a json string for data

    http://jsfiddle.net/3ee390r4/14/

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    There are basically two options for this:

    1. As you have done inject into the DOM on draw - which is the easiest way, but you need to do as you have done and explicitly add the data to show (in fairness since its an array you could just loop over it which would make it smaller if you have lots of columns).
    2. Implement a custom sort method that would keep that row always at the top. That is something that we plan to work on.

    Allan

  • marcellomarcello Posts: 8Questions: 1Answers: 0

    I tried replacing that string with the fnAddData, but then it just adds an insane amount of data. is there anyway to stop that from happening?

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    The legacy fnAddData method (or the newer row.add()) will insert the row wherever the DataTable deems it should be sorted to, so I'm not sure that would be useful in this case?

    Allan

  • marcellomarcello Posts: 8Questions: 1Answers: 0
    edited August 2016

    oh ok. so the way I did it is how I needs to be.

    My problem is that the data on that new roll needs to be calculated and I can't find a way to access the functions required to do those calculations

  • marcellomarcello Posts: 8Questions: 1Answers: 0

    my problem is that that new roll has some custom data, and the functions to calculate that data are outside the scope..

    so I can't figure out how to access those functions

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Without being able to see the full page I'm afraid there isn't much help I can offer in that regard.

  • marcellomarcello Posts: 8Questions: 1Answers: 0
  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Thanks - however, I'm afraid I'm not sure what I'm meant to do on that page. It is import / export options and I have no data to import.

    Allan

  • marcellomarcello Posts: 8Questions: 1Answers: 0
    edited August 2016

    Oh sorry, let me attach a sample.

    Copy paste into the import box and hit import, the table I'm having problems with is the on the Optimizer tab

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    I get some green text saying the data has been imported, but no DataTable. What do I do next? Sorry to ask questions, but this is obviously a new system to me so I'm not familiar with how to use it and in order to offer any help I will need guidance on how to actually see the error.

    Allan

  • marcellomarcello Posts: 8Questions: 1Answers: 0

    Oh, sorry, go to the Optimizer tab and just select a few options and click go. It should populate the table.`

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    I keep getting "There are no mods matching your preferences for slot 2!".

    Can you please give me explicit step by step instructions.

This discussion has been closed.