ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: omerix on May 26, 2014, 01:00:37 pm
-
Hello Param,
I can save the cell content if I hit (keydown=38) or (keydown=40).
However if I reenter same value it returns (TypeError: k is undefined).
There was a usage as below for "Pqgridcellsave" function. It returns "pqgridcelleditkeydown" ui.oldVal as undefined
var oldVal= ui.oldVal;
var newVal= ui.newVal;
if ((keyCode == 40 || keyCode == 38) [b]&& newVal != oldVal[/b])
Can I use "pqgridcelleditkeydown" instead of "Pqgridcellsave"?
I remember correct, this function does not response sometime. Please advise?
Video: http://youtu.be/swuV7TJ-JMQ (http://youtu.be/swuV7TJ-JMQ) (27:00-33:00)
pqgridcelleditkeydown function
$grid.on("pqgridcelleditkeydown", function( event, ui ) {
console.log(ui.oldVal);
keyCode=event.keyCode;
if (keyCode == 40 || keyCode==38) {
update(ui.rowIndx,ui.colIndx,keyCode);
}
});
update function
function update(rowIndx,colIndx,UpdateType) {
if (!$grid.pqGrid("saveEditCell")) {
return false;
}
var rowData = $grid.pqGrid("getRowData", { rowIndx: rowIndx });
var isValid = $grid.pqGrid("isValid", { rowData: rowData }).valid;
if (!isValid) {
return false;
}
var isDirty = $grid.pqGrid("isDirty");
if (isDirty) {
var recIndx = $grid.pqGrid("option", "dataModel.recIndx");
var url = "<%=dosya%>?isl=GridKaydet";
if (rowData[recIndx] == null) {
url = "<%=dosya%>?isl=GridKaydet";
}
$.ajax($.extend({}, ajaxObj, {
url: url,
data: rowData,
success: function (data,textStatus,jqXHR) {
if (data.prkod==0) {
$grid.pqGrid("removeClass", {rowIndx:rowIndx, cls: 'ui-state-error'} );
var recIndx = $grid.pqGrid("option", "dataModel.recIndx");
if (rowData[recIndx] == null) {
rowData[recIndx] = data.recIndx;
}
rowData['CevapResim'] = data.CevapResim;
$grid.pqGrid("commit");
if (UpdateType=="40") {
$grid.pqGrid("editCell", {
rowIndx: (rowIndx + 1),
colIndx: colIndx
});
};
if (UpdateType=="38") {
$grid.pqGrid("editCell", {
rowIndx: (rowIndx - 1),
colIndx: colIndx
});
}
}
else {
$grid.pqGrid("addClass", {rowIndx:rowIndx, cls: 'ui-state-error'} );
$('<div></div>').html('Hata Kodu:'+data.prkod+'<br>'+data.prnot).dialog({position: ['center','top'],modal:true,zindex:9002,title:'Kayıt Hatası'});
}
},//success
beforeSend: function(jqXHR, settings){
},//beforeSend
error: function(jqXHR, textStatus, errorThrown){
$('<div></div>').html('Hata Kodu:'+jqXHR.status+'<br>'+jqXHR.statusText).dialog({position: ['center','top'],modal:true,zindex:9002,title:textStatus});
},//error
complete:function(jqXHR, textStatus) {
}//complete
}));
$grid.pqGrid("editCell", { rowIndx: rowIndx, colIndx: colIndx });
}
else {
$grid.pqGrid("refreshRow", { rowIndx: rowIndx });
}
}
-
Omer
While inline editing, the events happen in this sequence: cellEditKeyDown, cellBeforeSave, cellSave. cellEditKeyDown is always fired when you input a key in an editor. cellBeforeSave is fired only when a save key such as tab or enter is pressed and this event occurs before cell is actually saved. cellSave is fired after a cell is saved successfully.
I hope it would help you to decide which event to choose.
Could you please get full stack trace of the error. ( k is undefined ). you can get full stack trace by using pqgrid.dev.js instead of pqgrid.min.js
May I know why are you using cellSave event. ui.oldVal would be undefined if the old value of the data in cell is indeed undefined. It can be avoided by setting initial data in cells to be "" or null when you use method to add rows i.e. addRow.
Could you please send an entire working test case so that I can have a look what's going on and what is your goal. You can replace the server side dependencies by replacing server side response with json files e.g., response.json
-
Hello param.
pqgrid.dev.js Version:2.0.4
Console error message: Row:3714
TypeError: column is undefined dataIndx = column.dataIndx,
I'm trying thank you.
-
Hello Param,
I have update my system to Pqgrid 2.1.0. Most functions are ok now.
I have used pqgrideditorkeydown instead of pqgridcelleditkeydown. I have review the script according tp API documents and it is ok now.
But span "SPAN ONCLICK"'s which are next to special editor, are not working now. When I click that it goes back to editor. Besides "ONKEYUP" is described in "SPAN" but it is working.
editor: {type: renkSec}
var renkSec = function (ui) {
var $cell = ui.$cell,
rowData = ui.rowData,
dataIndx = ui.dataIndx,
width = parseInt(ui.column.width) - 20,
cls = ui.cls;
var dc = $.trim(rowData[dataIndx]);
url = "pm/popup.asp?t=52&l=mr&fa=MODEL&fo=0&fv=" + ui.rowData.MODEL;
$cell.append("<input type='text' name='" + dataIndx + "' value='" + dc + "' class='" + cls + " fl' id='renk' onkeyup=\"PopupRL('" + url + "',event);\" style='z-index: 4;width:" + width + "px;'/>" +
"<span class='ui-widget-header fl ek' onclick=\"Popup('" + url + "','POPUP',540,550,10,400);\"><i class='ui-icon ui-icon-search ck'></i></span>");
$cell.find("input").focus();
$cell.find(".ui-icon-image").click(function () {
var theURL = "GenelEkTinymce.asp?isl=tc&type=image&field_name=";
Popup(theURL, "myWin", 640, 440, 100, 200);
});
};
And popup window "window.opener.$('.pq-edit-focus').val('test');" not work.
window.opener.$('.pq-edit-focus').val('test');
window.opener.$('.pq-edit-focus').focus();
window.close();
-
Omer
I'm unable to test your editor. Its dependencies i.e., css and popup functions are missing. Could you please provide a complete test case.
But span "SPAN ONCLICK"'s which are next to special editor, are not working now. When I click that it goes back to editor.
use editModel.onBlur = null
-
Thanks Paramvir
works very well ;D