jQuery UI Widgets Forums Grid How to get nested grid data in 1 postback

This topic contains 3 replies, has 2 voices, and was last updated by  JOlmos 9 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • How to get nested grid data in 1 postback #65471

    JOlmos
    Participant

    Hello,

    I have a nested grid that uses the data from two different record sets (tables) resulting from 1 query in MS SQL; I want to populate the parent grid and the child grid without having to do two calls (postbacks)to the db to get each table (all data is loaded in the first call to the db). Can this be done? Can I re-use the data adapter and just change the “record” property or something?

    ————-XML SAMPLE

    <Item>
    <ItemID>424</ItemID>
    <DateAdded>2015-01-07T11:08:00-08:00</DateAdded>
    <Item>Item1</Item>
    </Item>
    <Item>
    <ItemID>426</ItemID>
    <DateAdded>2015-01-08T10:04:00-08:00</DateAdded>
    <Item>Item2</Item>
    </Item>
    <ItemDetail>
    <DetailID>11</DetailID>
    <ItemID >424</ItemID>
    <Description>Item 1 Description</Description>
    </ItemDetail >
    <ItemDetail>
    <DetailID>12</DetailID>
    <ItemID >426</ItemID>
    <Description> Item 2 Description </Description>
    </ItemDetail >

    —–
    $(document).ready(function () {
    //Load the item adapter
    var source = {
    datafields: [
    { name: ‘ItemID’, type: ‘integer’ },
    { name: ‘DateAdded’, type: ‘date’ },
    { name: ‘Item’, type: ‘string’ },
    ],
    datatype: “xml”,
    async: false,
    record: ‘Item’,
    id: ‘ItemID’,
    url: ‘Default.aspx/GetItems’
    };
    var itemsDataAdapter = new $.jqx.dataAdapter(source,
    { contentType: ‘application/json; charset=utf-8’ });

    var cardsSource = {
    dataFields: [
    { name: ‘DetailID’, type: ‘integer’ },
    { name: ‘ItemID’, type: ‘integer’ },
    { name: ‘Description’, type: ‘string’ },
    ],
    datatype: “xml”,
    async: false,
    record: ‘ItemDetail’,
    id: “DetailID”,
    url: ‘Default.aspx/GetItemsDetail’ <—–I want to avoid this since the data was retrieved when I called ‘Default.aspx/GetItems’
    };
    var cardsDataAdapter = new $.jqx.dataAdapter(cardsSource,
    { contentType: ‘application/json; charset=utf-8’, autoBind: true });


    Dimitar
    Participant

    Hello JOlmos,

    It would be possible to pass the first data adapter’s records (itemsDataAdapter.records) as a localdata to the second data adapter (no need to set url in this case). That way, only one server call will be made.

    Best Regards,
    Dimitar

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


    JOlmos
    Participant

    Dimitar,

    Thank you for your response. I did what you had suggested, but there is a problem. The itemsDataAdapter contains all of the records for the Item nodes of the XML, I need to get all of the records that have ItemDetail nodes.

    How to get nested grid data in 1 postback #65537

    JOlmos
    Participant

    I got it working…

    I created a top level adapter and my grid adapters used the top level adapter to get their data. I used “topDataAdapter.xhr.responseText” as my localdata.

    Thank you for your help.

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

You must be logged in to reply to this topic.