jQWidgets Forums

jQuery UI Widgets Forums Grid spread sheet help

Tagged: ,

This topic contains 2 replies, has 2 voices, and was last updated by  ulao 12 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • spread sheet help #16491

    ulao
    Member

    I’m trying to load json data in the spread sheet example. It looks like it is loading the data but its blank? I was successful loading it in to a normal grid. When loading in to the spread sheet the rows number from 1 – 3 and this is correct as I have 3 rows of data in my json.

    Here is the spread sheet code I’m using.

    $(document).ready(function () {
    var theme = getDemoTheme();
    var url = “api/DB/”;

    // renderer for grid columns.
    var columnrenderer = function (value) {
    return ‘

    ‘ + value + ‘

    ‘;
    }

    // renderer for grid cells.
    var numberrenderer = function (row, column, value) {
    return ‘

    ‘ + (1 + value) + ‘

    ‘;
    }

    // create Grid datafields and columns arrays.
    var datafields = [];
    var columns = [];
    for (var i = 0; i < 26; i++) {
    var text = String.fromCharCode(65 + i);
    if (i == 0) {
    var cssclass = 'jqx-widget-header';
    if (theme != '') cssclass += ' jqx-widget-header-' + theme;
    columns[columns.length] = { pinned: true, exportable: false, text: "", columntype: 'number', cellclassname: cssclass, cellsrenderer: numberrenderer };
    }
    datafields[datafields.length] = { name: text };
    columns[columns.length] = { text: text, datafield: text, width: 60, renderer: columnrenderer };
    }

    var source =
    {
    datatype: "json",
    unboundmode: true,
    totalrecords: 100,
    datafields: datafields,
    id: 'id',
    url: url
    };

    var dataAdapter = new $.jqx.dataAdapter(source);

    // initialize jqxGrid
    $("#jqxgrid").jqxGrid(
    {
    width: 670,
    source: dataAdapter,
    editable: true,
    columnsresize: true,
    selectionmode: 'multiplecellsadvanced',
    theme: theme,
    columns: columns
    });
    });

    Also I was wondering if there was a double click on cell 0,0 for select all, and click on row/col to select that row or col option?

    spread sheet help #16503

    Peter Stoev
    Keymaster

    Hi ulao,

    The Spreadsheet sample is a Grid in unbound mode which means that it is implemented without data binding. Setting cell values in unbound mode should be done either manually or via the “setcellvalue” method. If you need to bind the Grid to some data, do not use “unbound” mode.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    spread sheet help #16543

    ulao
    Member

    understood. I was able to make my data load by setting my column/datafield names to match my data. Is there a way to load data in anonymously?

    Here is what I had to do to get data to show.

    var source =
    {
    datatype: “json”,
    totalrecords: 3,
    datafields: [
    { name: ‘Name’, type: ‘string’ },
    { name: ‘ID’, type: ‘number’ },
    ],
    id: ‘id’,
    url: url
    };

    var dataAdapter = new $.jqx.dataAdapter(source);
    // initialize jqxGrid
    $(“#jqxgrid”).jqxGrid(
    {
    width: 670,
    source: dataAdapter,
    editable: true,
    columnsresize: true,
    selectionmode: ‘multiplecellsadvanced’,
    theme: theme,
    columns: [
    { text: ‘Name’, datafield: ‘Name’, width: 100 },
    { text: ‘ID’, datafield: ‘ID’, width: 100 },

    ]
    });

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

You must be logged in to reply to this topic.