jQWidgets Forums

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts

  • 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);


    realtime
    Participant

    oh my god!! i got the solution. The fuc… name of the field was incorrect. 2 days with this 🙁

    sorry guys.


    realtime
    Participant

    The data adapter when rendergridrows try to return the data has the totalrecords property ok with 16 records, the records property with 10 elements but these elements are empty and the recordids property with 10 elements but here i see the data ok.

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