jQWidgets Forums

jQuery UI Widgets Forums Grid JSON data webservice incl. row count

This topic contains 5 replies, has 2 voices, and was last updated by  hf 12 years, 1 month ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • JSON data webservice incl. row count #19996

    hf
    Participant

    Hi,

    I’m trying to return json data from out of webservice incl. total row count, like explained in http://www.jqwidgets.com/jquery-widgets-documentation/documentation/asp.net-integration/asp.net-grid-paging-sorting-filtering.htm. But when I do merge the data with the total record variable into the json variable, I do have a empty grid.

    I think the format of the json string is wrong but can’t find it..

    Dim cmd As MySqlCommand = New MySqlCommand(query)

    Dim data = GetData(cmd)
    Dim merged = “{‘count’:'” & GetTotalRowsCount() & “‘, ‘data’:'” & data & “‘}”
    Dim json As String = New JavaScriptSerializer().DeserializeObject(merged)

    Return json

    The json string is resulting in:

    “{
    ‘count’:’53006′,
    ‘data’:'[
    {“id”:66666,”user”:1,”datum”:”\/Date(1367272800000)\/”,”totaal”:8.25},
    {“id”:66665,”user”:26,”datum”:”\/Date(1367272800000)\/”,”totaal”:7.75},
    {“id”:66664,”user”:26,”datum”:”\/Date(1367186400000)\/”,”totaal”:7.75},
    {“id”:66677,”user”:6,”datum”:”\/Date(1366927200000)\/”,”totaal”:7},
    {“id”:66663,”user”:26,”datum”:”\/Date(1366927200000)\/”,”totaal”:6},
    {“id”:66668,”user”:2,”datum”:”\/Date(1366840800000)\/”,”totaal”:2.25},
    {“id”:66675,”user”:3,”datum”:”\/Date(1366840800000)\/”,”totaal”:4},
    {“id”:66676,”user”:6,”datum”:”\/Date(1366840800000)\/”,”totaal”:2.5},
    {“id”:66674,”user”:9,”datum”:”\/Date(1366840800000)\/”,”totaal”:2.5},
    {“id”:66679,”user”:21,”datum”:”\/Date(1366840800000)\/”,”totaal”:4.25}
    ]’
    }”

    In the beforeprocessing function I’ll get my rowcount on data.d.count, but none of my real data rows…

    Help would be appreciated!

    JSON data webservice incl. row count #19997

    Peter Stoev
    Keymaster

    Hi,

    Could you post the code from the beforeprocessing function, too?

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    JSON data webservice incl. row count #19998

    hf
    Participant

    beforeprocessing: function (data) {
    var returnData = {};
    data = data.d;
    totalrecords = data.count;
    returnData.totalrecords = data.count;
    returnData.records = data.data;
    return returnData;
    },
    beforeprocessing: function (data) {
    source.totalrecords = data.d.count; // 100; //data.TotalRows;
    return data.d;
    },

    JSON data webservice incl. row count #20017

    Peter Stoev
    Keymaster

    Hi,

    Why do you define beforeprocessing function 2 times in your code? The first seems to be correct, but the second one is not.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    JSON data webservice incl. row count #20020

    hf
    Participant

    Yes I removed the second, but then it still didn’t worked out.

    I changed
    returnData.records = data.data;
    to
    returnData.records = JSON.parse(data.data);

    Now it works!

    JSON data webservice incl. row count #20031

    hf
    Participant

    One more thing related to the server side filtering..

    When I filter on a date field the formatdata function formats the date value (filtervalue0) as follow: Sun Apr 21 00:00:00 UTC+0200 2013

    How can I achieve that this format is for example equal to the cellsformat (cellsformat: ‘dd-MM-yyyy’)?

    Regards!

    { text: ‘datum’, dataField: ‘datum’, cellsformat: ‘dd-MM-yyyy’, filtertype: ‘date’, pinned: true, minwidth: 180 },

    formatdata: function (data) {
    data.pagenum = data.pagenum || 0;
    data.pagesize = data.pagesize || 10;
    data.sortdatafield = data.sortdatafield || ‘datum’;
    data.sortorder = data.sortorder || ‘desc’;
    data.filterscount = data.filterscount || 0;
    formatedData = buildQueryString(data);
    return formatedData;
    },

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.