Ajax

Ajax

freecexfreecex Posts: 25Questions: 4Answers: 0

How can I pass my model to datatable loading ajax?

"ajax": {
"url": "../YieldUP/Stiuazioni/LoadListaStorico",
"data": <----- ???????,
"type": "POST",
"datatype": "json" },

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    Take a look at the ajax.data docs. If that doesn't help please provide more detail about your question.

    Kevin

  • freecexfreecex Posts: 25Questions: 4Answers: 0

    I read that but I can't find a solution.
    That's the point (implementing mvc project).

    I'm loading my datatable: on ajax param, I'd like to call an Actionresult, passing all common data (draw, sprtcolumns, etc etc) added to my model on my page.

    How can I do it?

  • freecexfreecex Posts: 25Questions: 4Answers: 0

    Solved this problem.
    Now the last one: yesterday I mentioned my dt has 50 columns... thats not true.
    I'll have 10 + a number defined by the user.... how can I manage this? ist it possible ?
    I have to create a column list depending on an array contained into my controller result.....

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946
    Answer ✓

    Sounds like you would get the column list via ajax request?

    The columns definition is simply an array of objects that can be created using Javascript then assigned to the columns option. This will need to be done before Datatables is initialized. Here is an example I built that pulls the column names from the first object in the data array. Your server can return a different object with just the column definitions.

    Note also that an external ajax config is used and the data option is used to provide Datatables the data on initialization.

    http://live.datatables.net/fafuyeyu/55/edit

    Kevin

This discussion has been closed.