Forum
13:49
14/12/2013
Hi,
I want to have a multi select with control and Shift and keyboard navigation. And on double the row the row should be in editable mode.
To achive these functionalities I used ondblClickRow, MultiSelect, beforeSelectRow.
In the beforeSelectRow I am handling the Multiselect functionality (with shift key to select a range of rows. ). ondblClickRow will make my set the row to editable mode. But the prob with my code is, on dbl clicking the another row, ideally speaking the currently selected row should be in editable mode and previously selected row should not show up in edit mode. But here I get both the rows in editable mode. Please help me with the solution.
Please fnd the code below:
$(function () {
$("#editgrid").jqGrid({
url: 'WebForm7.aspx?q=1', datatype: "json", mtype: "POST",
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Closed', 'Ship via', 'Notes'],
colModel: [{ name: 'id', key: true, index: 'id', width: 55, editable: false, editoptions: { readonly: true, size: 10 } },
{ name: 'invdate', index: 'invdate', width: 80, editable: true, editoptions: { size: 10 } },
{ name: 'name', index: 'name', width: 90, editable: true, editoptions: { size: 25 } },
{ name: 'amount', index: 'amount', width: 60, align: "right", editable: true, editoptions: { size: 10 } },
{ name: 'tax', index: 'tax', width: 60, align: "right", editable: true, editoptions: { size: 10 } },
{ name: 'total', index: 'total', width: 60, align: "right", editable: true, editoptions: { size: 10 } },
{ name: 'closed', index: 'closed', width: 55, align: 'center', editable: true, edittype: "checkbox", editoptions: { value: "true:false" } },
{ name: 'ship_via', index: 'ship_via', width: 70, editable: true, edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT" } },
{ name: 'note', index: 'note', width: 100, sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "2", cols: "20" } }],
rowNum: 10, rowList: [10, 20, 30],
jsonReader: {
page: "page",
total: "total",
records: "records",
root: "rows",
repeatitems: false
},
pager: '#pagered',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: "Search Example",
hidegrid: false,
loadonce: true,
height: 400,
ondblClickRow: function () {
var row_id = $("#editgrid").getGridParam('selrow');
jQuery('#editgrid').jqGrid('restoreRow', lastsel2);
jQuery('#editgrid').editRow(row_id, true);
lastsel2 = row_id;
},
multiselect: true,
beforeSelectRow: function (rowid, e) {
if (!e.ctrlKey && !e.shiftKey) {
$(this).jqGrid('resetSelection');
}
else if (e.shiftKey) {
var initialRowSelect = $(this).jqGrid('getGridParam', 'selrow');
$(this).jqGrid('resetSelection');
var CurrentSelectIndex = $(this).jqGrid('getInd', rowid);
var InitialSelectIndex = $(this).jqGrid('getInd', initialRowSelect);
var startIndex, endIndex;
if (CurrentSelectIndex > InitialSelectIndex) {
startIndex = InitialSelectIndex;
endIndex = CurrentSelectIndex;
}
else {
startIndex = CurrentSelectIndex;
endIndex = InitialSelectIndex;
}
var dataIDs = $(this).getDataIDs();
for (var i = startIndex; i <= endIndex; i++) {
$(this).jqGrid('setSelection', dataIDs[i - 1], false);
}
return false;
}
return true;
},
editurl: "WebForm7.aspx/UpdatePerson"
});
jQuery("#editgrid").navGrid('#pagered', {
edit: true, add: true, del: true, search: true, editheight: 800
});
jQuery("#editgrid").jqGrid('bindKeys');
});
Most Users Ever Online: 715
Currently Online:
69 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66