Thanks Tony, I’ll give that a try.
What if I wanted to display a count of rows in place or next to the subgrid icon, any thoughts?
I sent it to support at trirand dot com.
I will resend it from another client.
Hi Tony,
Is there any way to change this to a span vs select.
Also is there any way to do a loading image while waiting for the server to send the select options?
Hi Tony,
I sent the whole jqGrid setup by email as requested.
Any update as to why the event is not raised?
Hi Tony,
Building the select on the server side.
Only downside to an empty option value and text of “No Rows Available” allows the client to send the request where for the server to process.
Our thinking was adding a span or making the select readonly would eliminate the possibility of the client sending the empty request.
Also we need to add a loading image for the select. At times when the server is busy or the select is large it takes a moment for the select to populate.
I did so many things, I’m not really sure what I did to fixed it.
Updated jqgrid to 4.7.1
Changed subgrid loadonce to false.
And a lot more…
here’s the working code.
$(document).ready(function () {
var _rowid;
$(“#jqGrid”).jqGrid({
url: ‘DataFiles.htm’,
mtype: “POST”,
datatype: “json”,
postData: {oper:’load’,mode:’assistant’,method:’data’},
colModel: [
{ label: ‘AgentID’, name: ‘AgentID’, index: ‘AgentID’, hidden: false, key: true },
{ label: ‘OfficeID’, name: ‘OfficeID’, index: ‘OfficeID’, hidden: true },
{ label: ‘Name’, name: ‘Name’, index: ‘Name’, hidden: false, width: 250, align: ‘left’, editable: false, search: true },
{ label: ‘Office’, name: ‘Office’, index: ‘Office’, hidden: false, width: 400, align: ‘left’, editable: false, search: true },
{ label: ‘User Cass’, name: ‘UserClass’, index: ‘UserClass’, hidden: false, width: 150, align: ‘left’, editable: false, search: true },
{ label: ‘Status’, name: ‘Status’, index: ‘Status’, hidden: false, width: 100, align: ‘center’, editable: false, search: true },
{ label: ‘Assistants’, name: ‘Assistants’, index: ‘Assistants’, hidden: false, width: 100, align: ‘center’, editable: false, search: true }
],
sortable: true,
viewrecords: true,
ignoreCase: true,
height: 300,
width: 900,
rowNum: 40,
rowList: [40, 80, 100, 200],
pager: “#jqGridPager”,
subGridBeforeExpand: function(divid, rowid) {
_rowid = rowid;
var expanded = jQuery(“td.sgexpanded”, “#jqGrid”)[0];
if(expanded) {
setTimeout(function(){
$(expanded).trigger(“click”);
}, 100);
}
},
jsonReader: {
subgrid : { repeatitems: false}
},
subGrid: true, // set the subGrid property to true to show expand buttons for each row
subGridRowExpanded: showChildGrid, // javascript function that will take care of showing the child grid
subGridOptions: {
“plusicon” : “ui-icon-triangle-1-e”,
“minusicon” : “ui-icon-triangle-1-s”,
“openicon” : “ui-icon-arrowreturn-1-e”,
“reloadOnExpand” : false,
“selectOnExpand” : true
}
});
$(‘#jqGrid’).navGrid(“#jqGridPager”, {
search: true, // show search button on the toolbar
add: false,
edit: false,
del: false,
refresh: true
},
{}, // edit options
{}, // add options
{}, // delete options
{) // search options – define multiple search
);
function showChildGrid(parentRowID, parentRowKey) {
var childGridID = parentRowID + “_table”;
var childGridPagerID = parentRowID + “_pager”;
var _officeid = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “OfficeID”);
var _agentid = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “AgentID” );
$(‘#’ + parentRowID).append(‘<table id=’ + childGridID + ‘></table><div id=’ + childGridPagerID + ‘ class=scroll></div>’);
$(“#” + childGridID).jqGrid({
url: ‘DataFiles.htm’,
editurl: ‘DataFiles.htm’,
mtype: “POST”,
datatype: “json”,
postData: {oper:’loadsubgrid’,mode:’assistant’,method:’data’,AgentID: _agentid,OfficeID: _officeid},
page: 1,
colModel: [
{ label: ‘Agent ID’, name: ‘pAgentID’, align: “left”, width: 300, key: true, index: ‘pAgentID’ },
{ label: ‘Personal Assistant’, name: ‘pName’, align: “left”, width: 400, stype:’select’, editable: true, edittype:”select”,
editoptions: {
dataUrl: ‘DataFiles.htm?oper=loadselect&mode=assistant&method=data&parent_id=’ + _rowid + ‘&OfficeID=’ + _officeid + ‘&AgentID=’ + _agentid
}
}
],
width: 500,
height: ‘100%’,
pager: “#” + childGridPagerID//,
});
$(“#” + childGridID).navGrid(“#” + childGridPagerID, {
search: false, // show search button on the toolbar
add: true,
edit: false,
del:true,
refresh: true
},
{}, // edit options
{ // add options
mtype: “POST”,
closeAfterAdd: true,
closeAfterEdit:true,
reloadAfterSubmit: true,
addCaption: “Add Personal Assistanat”,
bSubmit : “Add”,
bCancel : “Cancel”,
left:250,
top: 200,
onclickSubmit: function(rowid){
_OfficeID = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “OfficeID”);
_AgentID = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “AgentID”);
var val = $(this ).getCell(rowid, ‘pAgentID’);
return {oper:’add_subgrid_row’,mode:’assistant’,method:’data’,parent_id:_rowid,OfficeID:_OfficeID,AgentID:_AgentID };
},
afterSubmit : function(response, postdata)
{
success = true;
message = ‘OK’;
new_id = 1;
//this forces true always, need more work here for error checking
_Assistants = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “Assistants”);
_Assistants = parseInt( _Assistants ) + 1;
$(“#jqGrid”).jqGrid(‘setCell’, _rowid, ‘Assistants’, _Assistants);
return [true,”,”];
}
},
{ // delete options
mtype: “POST”,
onclickSubmit: function(rowid){
var myGrid = $(“#” + childGridID);
selRowId = myGrid.jqGrid (‘getGridParam’, ‘selrow’),
celValue = myGrid.jqGrid (‘getCell’, selRowId, ‘pAgentID’);
_OfficeID = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “OfficeID”);
_AgentID = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “AgentID”);
_Assistants = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “Assistants”);
_Assistants = parseInt( _Assistants ) – 1;
$(“#jqGrid”).jqGrid(‘setCell’, _rowid, ‘Assistants’, _Assistants);
return {oper:’del_subgrid_row’,mode:’assistant’,method:’data’,parent_id:_rowid,AgentID: _AgentID, OfficeID:_OfficeID };
},
//need more work here for error checking, possibly in afterSubmit
beforeShowForm: function(form) {
_this_row = jQuery( this ).jqGrid(‘getGridParam’,’selrow’);
_this_name = $( this ).jqGrid(“getCell”, _this_row, “pName”);
$(“td.delmsg”,form).html(“xDo you really want delete <b>” + _this_name + “</b>?”);
},
width:300,
addCaption: “Delete Personal Assistanat”,
left:250,
top: 200
},
{ // search options – define multiple search
//multipleSearch: true,
//multipleGroup: true,
//showQuery: true,
//groupOps: [ { op: “AND”, text: “and” }, { op: “OR”, text: “or” }, { op: “NOT”, text: “not” } ],
//matchText: ” match”
}
);
}
});
I’ve resolved the problem after making a number of changes to my original code.
All is working now.
Update,
The following code seems to close the add window but does not load the grid with the new row.
Is it necessary to insert the new row on the client side?
Or ca n a reloadGrid update the client from the server database with the new row in the database?
In either case i don’t see the new row on the client side, I do see it added to the database on the server side.
Also i don’t see the subgrid refresh on the server.
{ // add options
mtype: “POST”,
closeAfterAdd: true,
closeAfterEdit:true,
reloadAfterSubmit: true,
addCaption: “Add Personal Assistanat”,
bSubmit : “Add”,
bCancel : “Cancel”,
left:250,
top: 200,onclickSubmit: function(rowid){
_OfficeID = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “OfficeID”);
_AgentID = $(“#jqGrid”).jqGrid(“getCell”, _rowid, “AgentID”);
var val = $(this ).getCell(rowid, ‘pAgentID’);
return {oper:’add_subgrid_row’,mode:’assistant’,method:’data’,parent_id:_rowid,OfficeID:_OfficeID,AgentID:_AgentID };
},afterSubmit : function(response, postdata)
{
var myGrid = $(“#” + childGridID);
success = true;
message = ”;
new_id = ”;$(“.ui-icon-closethick”).trigger(‘click’); //this closes add window
myGrid.trigger(“reloadGrid”); //not working – suppose to reload grid,return [success,message,new_id]
}
},
Hi Tony,
For this post I’m using Chrome in OS X Yosemite.
.
I’m using a period (.) to separate paragraphs.
.
In this first code, it was pasted into the post, highlighted then clicked code editor, then clicked add
.
<pre class=”lang:js decode:true ” >
$(“#jqGrid”).navGrid(#jqGridPager, {
…
multipleSearch: true,
multipleGroup: true,
showQuery: true,
tmplNames: [Template One, Template Two],
tmplFilters: [template1, template2],
…
});
.
This code I clicked on code editor, then pasted the code into editor then clicked on add.
.
<pre class=”lang:js decode:true ” >
$(“#jqGrid”).navGrid(#jqGridPager, {
…
multipleSearch: true,
multipleGroup: true,
showQuery: true,
tmplNames: [Template One, Template Two],
tmplFilters: [template1, template2],
…
});
Tony
Oh I see the roadmap for Q1 2015.
.
We may need to look for another solution if it the release goes to March.
.
Regards,
Tony
Not sure, could have used a mac laptop or windows desktop last time.
.
I’m on the mac laptop now, browser is Safari v8.0.2, OS – Mac OS X Yosemite.
.
Copied the code above, pasted it into post, highlighted, then clicked code editor button.
.
<pre class=”lang:js decode:true ” >
//this code retuerns the current filter in use
var currentfilter = $(“#jqGrid”).jqGrid(‘getGridParam’,’postData’).filters;
//this is our setup for templNames and tmplFilters
$(“#jqGrid”).navGrid(#jqGridPager, {
…
multipleSearch: true,
multipleGroup: true,
showQuery: true,
tmplNames: [Template One, Template Two],
tmplFilters: [template1, template2],
…
});
var template1 =
{ “groupOp”: “AND”,
“rules”: [
{ “field”: “Account”, “op”: “eq”, “data”: “XYZ” },
{ “field”: “Name”, “op”: “cn”, “data”: “Smith”}
]
};
var template2 =
{ “groupOp”: “AND”,
“rules”: [
{ “field”: “Name”, “op”: “eq”, “data”: “Carnes” },
{ “field”: “OrderID”, “op”: “le”, “data”: “10255”}
]
};
OK, thanks.
Do you have a roadmap or schedule for your next release?
OK, this is a test
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
//this code retuerns the current filter in use var currentfilter = $("#jqGrid").jqGrid('getGridParam','postData').filters; //this is our setup for templNames and tmplFilters $("#jqGrid").navGrid(#jqGridPager, { ... multipleSearch: true, multipleGroup: true, showQuery: true, tmplNames: [Template One, Template Two], tmplFilters: [template1, template2], ... }); var template1 = { "groupOp": "AND", "rules": [ { "field": "Account", "op": "eq", "data": "XYZ" }, { "field": "Name", "op": "cn", "data": "Smith"} ] }; var template2 = { "groupOp": "AND", "rules": [ { "field": "Name", "op": "eq", "data": "Carnes" }, { "field": "OrderID", "op": "le", "data": "10255"} ] }; |
The code above…I pasted the code in the form, selected it and pressed code editor, then add.
Thank you.
.
Do you have any kind of time frame for this?
Setting recreateFilter to true results in template select element to default.
.
Problem is we need recreateFilter: true so we can add or delete filters but we do not want the template select to reset to default.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top