jQWidgets Forums

jQuery UI Widgets Forums Grid jqxgrid with 2 or more tables

This topic contains 1 reply, has 1 voice, and was last updated by  realtime 11 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • jqxgrid with 2 or more tables #55263

    realtime
    Participant

    I am trying to make a grid whith paging, ordering and filtering in asp.net.
    The source is a join of 2 tables.
    I´m following this example to make the aspx: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/asp.net-integration/asp.net-grid-paging-sorting-filtering.htm

    The code is ok and it works but is a nightmare to desing the same for a join of 2 tables because i dont know how to implement a function that generate the sql everytime the user clicks in a column to order or try to filter a column.

    Anyone has an example?

    jqxgrid with 2 or more tables #55398

    realtime
    Participant

    There is a valid solution for this using the values parameter but this is valid only when the foreing key has only one field. How can i make the same but with more than one field?

    This is the example for only one field:

    values – determines the foreign collection associated to the data field.

    Example with “values” This functionality allows you to join two or more data sources.

    var employeesSource =
    {
    datatype: “xml”,
    datafields: [
    { name: ‘FirstName’, type: ‘string’ },
    { name: ‘LastName’, type: ‘string’ }
    ],
    root: “Employees”,
    record: “Employee”,
    id: ‘EmployeeID’,
    url: “../sampledata/employees.xml”,
    async: false
    };

    var employeesAdapter = new $.jqx.dataAdapter(employeesSource, {
    autoBind: true,
    beforeLoadComplete: function (records) {
    var data = new Array();
    // update the loaded records. Dynamically add EmployeeName and EmployeeID fields.
    for (var i = 0; i < records.length; i++) {
    var employee = records[i];
    employee.EmployeeName = employee.FirstName + ” ” + employee.LastName;
    employee.EmployeeID = employee.uid;
    data.push(employee);
    }
    return data;
    }
    });

    // prepare the data
    var ordersSource =
    {
    datatype: “xml”,
    datafields: [
    // name – determines the field’s name.
    // value – the field’s value in the data source.
    // values – specifies the field’s values.
    // values.source – specifies the foreign source. The expected value is an array.
    // values.value – specifies the field’s name in the foreign source.
    // values.name – specifies the field’s value in the foreign source.
    // When the ordersAdapter is loaded, each record will have a field called “EmployeeName”. The “EmployeeName” for each record comes from the employeesAdapter where the record’s “EmployeeID” from orders.xml matches to the “EmployeeID” from employees.xml.
    { name: ‘EmployeeName’, value: ‘EmployeeID’, values: { source: employeesAdapter.records, value: ‘EmployeeID’, name: ‘EmployeeName’ } },
    { name: ‘EmployeeID’, map: ‘m\\:properties>d\\:EmployeeID’ },
    { name: ‘ShippedDate’, map: ‘m\\:properties>d\\:ShippedDate’, type: ‘date’ },
    { name: ‘Freight’, map: ‘m\\:properties>d\\:Freight’, type: ‘float’ },
    { name: ‘ShipName’, map: ‘m\\:properties>d\\:ShipName’ },
    { name: ‘ShipAddress’, map: ‘m\\:properties>d\\:ShipAddress’ },
    { name: ‘ShipCity’, map: ‘m\\:properties>d\\:ShipCity’ },
    { name: ‘ShipCountry’, map: ‘m\\:properties>d\\:ShipCountry’ }
    ],
    root: “entry”,
    record: “content”,
    id: ‘m\\:properties>d\\:OrderID’,
    url: “../sampledata/orders.xml”,
    pager: function (pagenum, pagesize, oldpagenum) {
    // callback called when a page or page size is changed.
    }
    };
    var ordersAdapter = new $.jqx.dataAdapter(ordersSource);

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

You must be logged in to reply to this topic.