doubt regarding dataSrc

doubt regarding dataSrc

SrilakshmiSrilakshmi Posts: 35Questions: 6Answers: 0
edited October 2014 in DataTables

Hi Allan,
I am using server side processing,
my doubt is regarding return type of "dataSrc",
if I use

 " dataSrc": function ( json ) {
                 MasterProducts = hostXmlToJson(json);
                 var json = JSON.stringify(MasterProducts);
                var result = json ;
                var obj = JSON.parse(result);
                 return obj.data;
                
              } 

it works fine, but the paging information is not proper, as it comes as Showing 0 to 0 of 0 entries (filtered from NaN total entries),
to solve this issue i used the following code

" dataSrc": function ( json ) {
                 MasterProducts = hostXmlToJson(json);
                 var json = JSON.stringify(MasterProducts);
                var result = json ;
                var obj = JSON.parse(result);
                return {
                    recordsTotal: 500, //500 used for checking purpose
                  recordFiltered: 30,//30 used for checking purpose
                  data: obj.data
                     };
           }

in this case data does not appear in the table at all.

looking forward for a reply,
Srilakshmi

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    Just a quick note, the Markdown formatting guidelines might be of some interest for syntax highlighting etc. I've edited your post above to ad syntax highlighting.

    There is no option in server-side processing mode to change the location of the recordsTotal, etc parameters - they must be at the top level of the JSON object returned. The ajax.dataSrc option is only for the data source.

    Allan

  • SrilakshmiSrilakshmi Posts: 35Questions: 6Answers: 0

    Thanks allan :-)

This discussion has been closed.