jQWidgets Forums
jQuery UI Widgets › Forums › Grid › spread sheet help
This topic contains 2 replies, has 2 voices, and was last updated by ulao 12 years, 3 months ago.
-
Authorspread sheet help Posts
-
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?
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 StoevjQWidgets Team
http://www.jqwidgets.comunderstood. 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 },]
}); -
AuthorPosts
You must be logged in to reply to this topic.