How to get column config of DataTable and feed it to DataTable dynamically ?

How to get column config of DataTable and feed it to DataTable dynamically ?

farhadtablefarhadtable Posts: 47Questions: 27Answers: 1

Before, in our old application we are using JQGrid free, as far as I am aware there are a lot's of feture in JQGrid that we can see some of them in DataTable,
before we are saving column state of jqgrid per users in DB and read back it while users get log-in,
now we migrate to DataTable but some feature are not easy to use ,
so my main issue is saving column state in DB and read it back to render, is there a way to get column config of DataTable and feed it to DataTable dynamically not static,ordering,visibility and so on...

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,572Questions: 1Answers: 10,482 Site admin

    Hi,

    Thanks for your question. This is actually one that is in the FAQs:

    Q. Can I define my columns in Ajax loaded JSON?

    The reason you can't currently do that using DataTables' configuration options is that JSON doesn't support Javascript functions, and thus you wouldn't be able to make use of all of the features of DataTables. Having said that, if you are happy with that fact, its just an extra line to use $.ajax to get the information from the server!

    Allan

  • farhadtablefarhadtable Posts: 47Questions: 27Answers: 1

    In fact, we now need to make this features ..
    Please write to me a solutions

  • farhadtablefarhadtable Posts: 47Questions: 27Answers: 1

    Is there a dll file in asp lib ?

  • allanallan Posts: 63,572Questions: 1Answers: 10,482 Site admin
    Answer ✓

    The method that the FAQ describes is exactly how you would do it:

    $.ajax( {
      url: ...
      success: function ( json ) {
        $('#myTable').DataTable( {
          columns: json.columns,
          data: json.data
         } );
      }
    } );
    

    Is there a dll file in asp lib ?

    The dll provided in the Editor .NET download is CLR, so it would work in ASP as well as the C# that it was originally written in.

    Allan

This discussion has been closed.