1
Help for ParamQuery Grid (free version) / Re: Use JSON to define colModel
« on: October 22, 2014, 09:17:02 pm »
Thanks for looking into this.
I checked the dpendency files and they seem all ok.
Also found "$.ajax ({ " is somehow not working ok. I replaced this with Jquery "$.getJSON('ttlookupcol.json'," and then it draws the grid(need this in a popup) and also populates ok.
$(function () {
/*Display gridObjectInPopup when lookup button clicked*/
$("#showlookup").click(function (evt) {
$.getJSON('ttlookupcol.json',
function (gridJSON) {
gridObject = {
width: 640,
height: 400,
selectionModel: { type: 'cell'},
colModel: gridJSON.columns,
dataModel: {
data: gridJSON.data
}
};
gridObject.cellSelect = function (evt, obj) {
var dataCell = obj.data[obj.rowIndx][obj.dataIndx];
$("#clientcode").attr('value', dataCell);
$("#pq-grid-in-popup-dialog").dialog('close');
};
//$("#pq-grid-in-popup-dialog").dialog('destroy');
$("#pq-grid-in-popup-dialog").dialog({
height: 300,
width: 500,
create: function (evt, ui) {
//$(this).detach().appendTo($("#pq-dialog-cont"));
},
open: function (evt, ui) {
var $grid = $("#grid_in_popup_grid");
var ht = $grid.parent().height() - 2;
var wd = $grid.parent().width() - 2;
//alert("ht=" + ht + ", wd=" + wd);
if ($grid.hasClass('pq-grid')) {
$grid.pqGrid("option", {
height: ht,
width: wd
});
} else {
gridObject.width = wd;
gridObject.height = ht;
$grid.pqGrid(gridObject);
}
//refresh the selections made before closing grid if any.
//$grid.pqGrid("selection", { type: 'cell', method: 'refresh' });
},
close: function () {
var $grid = $("#grid_in_popup_grid");
$grid.pqGrid('destroy');
},
resizeStop: function (evt, ui) {
var $grid = $("#grid_in_popup_grid");
var ht = $grid.parent().height();
var wd = $grid.parent().width();
$grid.pqGrid("option", {
height: ht - 2,
width: wd - 2
});
},
show: {
effect: "blind",
duration: 500
},
hide: {
effect: "explode",
duration: 500
}
}); /*$("#pq-grid-in-popup-dialog").dialog({*/
});
/********************/
});
});
However I am now facing another problem.
I need this functionality to support Remote data(json) plus remote sorting plus rempote paging. I tried the remote sorting demo example; and function geturl does'nt bring anything back. I am fetching same json file as I have fetched with "$.getJSON('ttlookupcol.json',"; and thus assume that location is ok. Or otherwise, how do I enable remote sorting by using the same code as above?
Could somebody please help me this;
I checked the dpendency files and they seem all ok.
Also found "$.ajax ({ " is somehow not working ok. I replaced this with Jquery "$.getJSON('ttlookupcol.json'," and then it draws the grid(need this in a popup) and also populates ok.
$(function () {
/*Display gridObjectInPopup when lookup button clicked*/
$("#showlookup").click(function (evt) {
$.getJSON('ttlookupcol.json',
function (gridJSON) {
gridObject = {
width: 640,
height: 400,
selectionModel: { type: 'cell'},
colModel: gridJSON.columns,
dataModel: {
data: gridJSON.data
}
};
gridObject.cellSelect = function (evt, obj) {
var dataCell = obj.data[obj.rowIndx][obj.dataIndx];
$("#clientcode").attr('value', dataCell);
$("#pq-grid-in-popup-dialog").dialog('close');
};
//$("#pq-grid-in-popup-dialog").dialog('destroy');
$("#pq-grid-in-popup-dialog").dialog({
height: 300,
width: 500,
create: function (evt, ui) {
//$(this).detach().appendTo($("#pq-dialog-cont"));
},
open: function (evt, ui) {
var $grid = $("#grid_in_popup_grid");
var ht = $grid.parent().height() - 2;
var wd = $grid.parent().width() - 2;
//alert("ht=" + ht + ", wd=" + wd);
if ($grid.hasClass('pq-grid')) {
$grid.pqGrid("option", {
height: ht,
width: wd
});
} else {
gridObject.width = wd;
gridObject.height = ht;
$grid.pqGrid(gridObject);
}
//refresh the selections made before closing grid if any.
//$grid.pqGrid("selection", { type: 'cell', method: 'refresh' });
},
close: function () {
var $grid = $("#grid_in_popup_grid");
$grid.pqGrid('destroy');
},
resizeStop: function (evt, ui) {
var $grid = $("#grid_in_popup_grid");
var ht = $grid.parent().height();
var wd = $grid.parent().width();
$grid.pqGrid("option", {
height: ht - 2,
width: wd - 2
});
},
show: {
effect: "blind",
duration: 500
},
hide: {
effect: "explode",
duration: 500
}
}); /*$("#pq-grid-in-popup-dialog").dialog({*/
});
/********************/
});
});
However I am now facing another problem.
I need this functionality to support Remote data(json) plus remote sorting plus rempote paging. I tried the remote sorting demo example; and function geturl does'nt bring anything back. I am fetching same json file as I have fetched with "$.getJSON('ttlookupcol.json',"; and thus assume that location is ok. Or otherwise, how do I enable remote sorting by using the same code as above?
Could somebody please help me this;