Ajax call won't run

Ajax call won't run

dgaynesdgaynes Posts: 6Questions: 0Answers: 0
edited February 2013 in General
New to databtables, my server-side function never gets called, anyone know why? Thanks. (when I call the now-empty function you see here directly I do get the expected Json results)
[code]
public class PagesController : Controller
{
public ActionResult AjaxMasterCatGrid(jQueryDataTableParamModel param)
{

// blah blah this does not matter it doesn't get hit, why?

}
}
$(document).ready(function () {

$('#tblCats').dataTable({
"bServerSide": true,
"sAjaxSource": "Pages/AjaxMasterCatGrid",
"bProcessing": true,
"aoColumns":
[
{
"sName": "Name",
"bSearchable": false,
"bSortable": true
},
{
"sName": "Code",
"bSearchable": false,
"bSortable": true
},
{
"sName": "IsPrecontract",
"bSearchable": false,
"bSortable": true
},
{
"sName": "IsActive",
"bSearchable": false,
"bSortable": true
}
]
});
});[/code]
(to be clear, it is "datatabling", I see the Search and so on, the js runs, I just get no data in the grid)

Replies

  • dgaynesdgaynes Posts: 6Questions: 0Answers: 0
    edited February 2013
    above
  • essexstephessexsteph Posts: 57Questions: 0Answers: 0
    If you look at the documentation for sAjaxSource it requires a URL (http://datatables.net/usage/server-side). It doesn't look like you're supplying one.

    Steph
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    @dgaynes - That looks like it should make the Ajax call. Please link to a test case showing the issue so we can help fix it: http://datatables.net/forums/discussion/12899

    Allan
  • dgaynesdgaynes Posts: 6Questions: 0Answers: 0
    OK, I got it running. Bad mapping from the View to the MVC controller holding the AJAX, you like the path relative evidently. (put it in the docs, yes?)

    Now the issue is that it won't page properly, it display all records no matter what.

    It does show the pager with four pages correctly [sized per the code below], I know this code is not crapping in the middle because I do get the 10, 20 ALL in my dropdown list defaulted to my chosen page size and when I change that list the pager changes to only two pages . . . but the full display of records does not change. Thanks for the help.

    $('#tblCats').dataTable({
    "iDisplayLength": 10,
    "bServerSide": true,
    "sAjaxSource": "AjaxMasterCatGrid",
    "bProcessing": true,
    "bPaginate": true,
    "sPaginationType": "full_numbers",
    "aLengthMenu": [
    [10, 20, -1],
    [10, 20, "All"]
    ]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > Bad mapping from the View to the MVC controller holding the AJAX, you like the path relative evidently. (put it in the docs, yes?)

    No - DataTables doesn't care if the path is relative or absolute. It just makes the request form the loaded page and the server will resolve it.

    > Now the issue is that it won't page properly, it display all records no matter what.

    Please link to a test case so we can debug and help fix it.

    Allan
  • dgaynesdgaynes Posts: 6Questions: 0Answers: 0
    Your reply notwithstanding, what I showed above did not work and the call from your js code needed to be just AjaxMasterCatGrid without the controller name. Using fiddler, the path revealed it was using was pages/pages/AjaxMasterCatGrid.

    Can you explain what you want when you say "link to a test case" and how this helps? Thanks.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited February 2013
    > Can you explain what you want when you say "link to a test case" and how this helps? Thanks.

    Link to the page that you are working on, or some other page that shows the issue you are seeing, so I can debug the page and figure out what exactly is happening, otherwise I don't know what is going wrong or why, nor do I have enough information to figure out why it is going wrong.

    Allan
  • dgaynesdgaynes Posts: 6Questions: 0Answers: 0
    For editing, how do you connect an ID field coming out of the database to the "ID" arg in datatables sent via AJAX? Is there a bID: true property for a column or something when you load the table?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    In Editor you would use `idSrc` - http://editor.datatables.net/options/#idSrc . For other editing methods, how it is implemented it up to whatever implementation you are using.

    Allan
  • dgaynesdgaynes Posts: 6Questions: 0Answers: 0
    I'm trying to use dataTables.editable.js. Do you know how to do it using that tool?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Nope sorry - not something that I use much myself. I guess you need to pull the data out of the table using fnGetData and then manipulate the parameters it is sending to the server based on the data for the row.

    Allan
This discussion has been closed.