jQuery UI Widgets Forums Grid How to populate jqxGrid from array?

This topic contains 1 reply, has 2 voices, and was last updated by  ivailo 8 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • How to populate jqxGrid from array? #72896

    shyselsasi
    Participant

    Hi

    I want to populate jqxGrid from an array DataItem = [];
    I tried like this.But data is not loaded.I can see only blank rows.What is ‘url’?
    // prepare the data
    var source1 =
    {
    datatype: “json”,
    datafields: [
    { name: ‘DataID’, type: ‘string’ },
    { name: ‘DataName’, type: ‘string’ }

    ],
    id: ‘dataID’,
    localdata: DataItem
    };
    var dataAdapter1 = new $.jqx.dataAdapter(source1);

    $(“#treeGrid”).jqxGrid(
    {
    width: 850,
    source: dataAdapter1,
    columnsresize: true,
    columns: [
    { text: ‘ID’, datafield: ‘DataID’, width: 250 },
    { text: ‘Name’, datafield: ‘DataName’, width: 250 }
    ]
    });

    Thanks in advance.

    How to populate jqxGrid from array? #72919

    ivailo
    Participant

    Hi shyselsasi,

    With your sesttings you are trying to populate from JSON.
    Here is your code with json data.

    If you want to populate from array you have 2 options:
    1. From associative array – similar to JSON. Here is the demo.
    2. From 2 dimentional array. Here is the demo.

    The source object represents a set of key/value pairs.
    url: A string containing the URL to which the request is sent.
    data: Data to be sent to the server.
    localdata: data array or data string pointing to a local data source.
    datatype: the data’s type. Possible values: ‘xml’, ‘json’, ‘jsonp’, ‘tsv’, ‘csv’, ‘local’, ‘array’, ‘observablearray’.
    type: The type of request to make (“POST” or “GET”), default is “GET”.
    id: A string containing the Id data field.
    root: A string describing where the data begins and all other loops begin from this element.
    record: A string describing the information for a particular record.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

    • This reply was modified 8 years, 11 months ago by  ivailo.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.