1
Help for ParamQuery Grid (free version) / Re: Use JSON to define colModel
« on: June 24, 2014, 11:59:45 pm »
Thanks. Must be my day for silly mistakes. The 'async' issue was just as dumb on my part.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
$(function() {
var gridObject = {};
var buildGrid = function(gridJSON) {
console.log(JSON.stringify(gridJSON));
gridObject = {
width: 640,
height: 400,
colModel: gridJSON.columns,
dataModel: gridJSON.data
};
console.log(JSON.stringify(gridObject));
};
$.ajax ({
url: 'data/facilitygrid.json',
type: 'GET',
dataType: 'JSON',
async: false,
success: buildGrid
});
$("#aGrid").pqGrid(gridObject);
});
{"columns":[
{"title":"Name","width":100,"dataType":"string","dataIndx":"facName"},
{"title":"Bldg","width":50,"dataType":"string","dataIndx":"facBldg"},
{"title":"Floor","width":50,"dataType":"string","dataIndx":"facFloor"},
{"title":"Column","width":50,"dataType":"string","dataIndx":"facColumn"},
{"title":"Room","width":50,"dataType":"string","dataIndx":"facRoom"},
{"title":"Class","width":50,"dataType":"string","dataIndx":"facClass"},
{"title":"Ready","width":100,"dataType":"string","dataIndx":"facReady"}],
"data":[
{"facName":"N-100","facBldg":"N","facFloor":"1","facColumn":"","facRoom":"100","facClass":"SAR","facReady":"12-31-2014"},
{"facName":"A1-11","facBldg":"M103","facFloor":"1","facColumn":"R29","facRoom":"","facClass":"DoD","facReady":"12-31-2014"}]}
{"width":640,"height":400,
"colModel":[
{"title":"Name","width":100,"dataType":"string","dataIndx":"facName"},
{"title":"Bldg","width":50,"dataType":"string","dataIndx":"facBldg"},
{"title":"Floor","width":50,"dataType":"string","dataIndx":"facFloor"},
{"title":"Column","width":50,"dataType":"string","dataIndx":"facColumn"},
{"title":"Room","width":50,"dataType":"string","dataIndx":"facRoom"},
{"title":"Class","width":50,"dataType":"string","dataIndx":"facClass"},
{"title":"Ready","width":100,"dataType":"string","dataIndx":"facReady"}],
"dataModel":[{"facName":"N-100","facBldg":"N","facFloor":"1","facColumn":"","facRoom":"100","facClass":"SAR","facReady":"12-31-2014"},
{"facName":"A1-11","facBldg":"M103","facFloor":"1","facColumn":"R29","facRoom":"","facClass":"DoD","facReady":"12-31-2014"}]}
{
"columns": [
{"title": "Name", "width": 100, "dataType":"string", "dataIndx":"facName"},
{"title": "Bldg", "width": 50, "dataType":"string", "dataIndx":"facBldg"},
{"title": "Floor", "width": 50, "dataType":"string", "dataIndx":"facFloor"},
{"title": "Column", "width": 50, "dataType":"string", "dataIndx":"facColumn"},
{"title": "Room", "width": 50, "dataType":"string", "dataIndx":"facRoom"},
{"title": "Class", "width": 50, "dataType":"string", "dataIndx":"facClass"},
{"title": "Ready", "width": 100, "dataType":"string", "dataIndx":"facReady"}
],
"data": [
{"facName": "N-100", "facBldg": "N", "facFloor": "1", "facColumn": "", "facRoom": "100", "facClass": "SAR", "facReady": "12-31-2014"},
{"facName": "A1-11", "facBldg": "M103", "facFloor": "1", "facColumn": "R29", "facRoom": "", "facClass": "DoD", "facReady": "12-31-2014"}
]
}
$(function() {
var facilityGridColumns = [
{title: "Name", width: 100, dataType:"string", dataIndx:"facName"},
{title: "Bldg", width: 50, dataType:"string", dataIndx:"facBldg"},
{title: "Floor", width: 50, dataType:"string", dataIndx:"facFloor"},
{title: "Column", width: 50, dataType:"string", dataIndx:"facColumn"},
{title: "Room", width: 50, dataType:"string", dataIndx:"facRoom"},
{title: "Class", width: 50, dataType:"string", dataIndx:"facClass"},
{title: "Ready", width: 100, dataType:"string", dataIndx:"facReady"}
];
var facilityGridObject = {
width: 640,
height: 400,
colModel: facilityGridColumns,
dataModel: {
location: "remote",
dataType: "JSON",
method: "GET",
getUrl: function() {
return {url:"data/facilitygrid.json"};
},
getData: function(dataJSON) {
var data = dataJSON.data;
return {data: dataJSON.data};
}
}
};
$("#facilityGrid").pqGrid(facilityGridObject);
});