ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: angelahlp on February 18, 2014, 12:17:22 am
-
I've set up a grid that has the autoCompleteEditor from the demos. When I change a value in the form isDirty is not true? Any help would be appreciated. Some snippets of code I'm using are below. I don't know if dataIndx has anything to do with it in the colModel - but if I add it, the value no longer displays in the grid.
//define custom editors
var autoCompleteEditor = function (ui) {
//debugger;
var $cell = ui.$cell,
rowData = ui.rowData,
dataIndx = ui.dataIndx,
width = ui.column.width,
cls = ui.cls;
var dc = $.trim(rowData[dataIndx]);
var userindex = '';
switch (dataIndx) {
case 2:
userindex = arr1;
break;
case 3:
userindex = arr2;
break;
}
var $inp = $("<input type='text' name='" + userindex + "' class='" + cls + " pq-ac-editor' />")
.width(width - 6)
.appendTo($cell)
.val(dc);
$inp.autocomplete({
source: (userindex),
minLength: 0
}).focus(function () {
//open the autocomplete upon focus
$(this).data("autocomplete").search($(this).val());
});
}
JSON data
{"COLUMNS":["RESOURCEID","RESOURCENAME","SIMULATORNAME","SIMULATORGROUP"],"DATA":[[624," Ambulance 502 Bravo (A502B)",null,"Federal Response","Fire Department Unit"],[594,"AFD Foam Unit",null,"Fire","Fire Department Unit"]...
colModel: [
{ title: "Resource ID", dataType: "integer", editable: false },
{ title: "Resource Name", width: 150, dataType: "string",
validations: [
{ type: 'minLen', value: 1, msg: "Required" },
{ type: 'maxLen', value: 255, msg: "length should be <= 255" }
]
},
{ title: "Simulator", width: 150,
editor: {
type: autoCompleteEditor
}
},
{ title: "Simulator Group", width: 150,
editor: {
type: autoCompleteEditor
}
}
],
-
You need to set primary key for isDirty to work.
http://paramquery.com/pro/api#option-dataModel-recIndx
BTW why are you setting name = userindex which is equal to "" in autoCompleteEditor? name should be equal to dataIndx.
You should better be using JSON data for this example e.g., data: [ { key: value, key2, value2 }....] where key & key2 are dataIndx for first and second column.
-
Thanks for your help! I was hoping for pqgrid to accept the JSON format I was sending as it is what ColdFusion sends as its standard... I took your advice and am trying to manually create the JSON string to send to the grid so that I can send it as key/value pairs... but now I can't get it to accept it. I've tried sending the JSON string in many formats from my CF CFC - this is the last attempt ( but also tried with "data:... ", etc.. Any Help is appreciated :)
[{resourceid: 624, resourcename: ' Ambulance 502 Bravo (A502B)'},{resourceid: 594, resourcename: 'AFD Foam Unit'},{resourceid: 593, resourcename: 'AFD HazMat Trailer'},{resourceid: 596, resourcename: 'AFD Rehab Bus'},{resourceid: 628, resourcename: 'Air 512 '},{resourceid: 513, resourcename: 'Alexandria Police Car 1'},{resourceid: 514, resourcename: 'Alexandria Police Car 2'},{resourceid: 515, resourcename: 'Alexandria Police Car 3'},{resourceid: 516, resourcename: 'Alexandria Police Car 4'},{resourceid: 517, resourcename: 'Alexandria Police Car 4'} ]
the code that accepts it as data is:
dataModel: {
dataType: "JSON",
location: "remote",
recIndx: "resourceid",
url: "/cfc/myfunctions.cfc?method=getResources",
getData: function (response) {
return { data: response };
}
},
-
Did you add matching dataIndx in column definitions of colModel
For your data it should be
colModel: [
{ title: "Resource ID", dataType: "integer", editable: false, dataIndx: 'resourceid' },
{ title: "Resource Name", width: 150, dataType: "string", dataIndx: 'resourcename',
validations: [
{ type: 'minLen', value: 1, msg: "Required" },
{ type: 'maxLen', value: 255, msg: "length should be <= 255" }
]
}]
-
I have tried this. What I'm getting is a character in each row in the resource id field from the JSON string.
resourceid resourcename
{
r
e
s
o
....
-
I finally got this working on my own--- thanks for the input.