How to create multiple jqgrid instances with jquery?











up vote
1
down vote

favorite












I have been trying jqgrid and is fantastic. After searching a lot, I havent found anything related to this topic, and some help would be great.



I need to create dynamically many jqgrid instances from jquery and append them into a list in html.



My problem is that the navGrid pagination div is not showing the add/edit default buttons, neither custom buttons added manually.



Here is the sample code:



function NewgJQGridInstance(houseHoldGridId, gridPlaceholder) {
//Local variables
var myGrid = $("<table>").attr("id", houseHoldGridId);
var myPager = $("<div>").attr("id", houseHoldGridId + "_pager");

function publicInit() {
gridPlaceholder.append(myGrid, myPager);
myGrid.jqGrid({
datatype: "local",
cellsubmit: 'clientArray',
height: 100,
width: 1300,
colModel: [
{ label: 'Cantidad', name: 'cantidad_menaje', index: 'cantidad_menaje', width: 120, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 5 } },
{ label: 'Menaje', name: 'menaje', index: 'menaje', width: 300, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 50, maxlength: 100 } },
{ label: 'Observaciones particulares del menaje', name: 'observaciones_menaje', index: 'observaciones_menaje', width: 750, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 10 } }
],
pager: myPager,
loadonce: true,
//pgbuttons: false,
//pgtext: null,
viewrecords: false,
loadError: function (jqXHR, textStatus, errorThrown) {
alertError('Error al cargar el grid', 'HTTP message body (jqXHR.responseText): ' + 'n' + jqXHR.responseText);
}
});
}
//Initialization
return {
init: publicInit
}
};

var gridDin = new NewgJQGridInstance("jq1234", cellWhereAppendTheGrid);
gridDin.init();


I have tried several ways of showing the navGrid buttons, but none of them worked for the moment.



My first approach was defining the navGrid pager like this:



myGrid.navGrid(myPager,
// the buttons to appear on the toolbar of the grid
{ edit: true, add: true, del: true, search: false, refresh: false, view: false, position: "left", cloneToTop: false },
// options for the Edit Dialog
{
url: 'clientArray',
editCaption: "Edición de elemento",
recreateForm: true,
beforeInitData: function () {
},
checkOnUpdate: false,
checkOnSubmit: false,
closeOnEscape: true,
beforeSubmit: function (postdata, form, oper) {
if (confirm('¿Deseas realmente modificar este registro?')) {
// do something
return [true, ''];
} else {
return [false, '¡La modificación no se ha guardado!'];
}
},
closeAfterEdit: true,
savekey: [true, 13],
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Add Dialog
{
url: 'clientArray',
closeAfterAdd: true,
closeOnEscape: true,
recreateForm: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Delete Dailog
{
url: 'clientArray',
recreateForm: true,
closeOnEscape: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
});


This case was not working, so I tried this other code more simple:



myGrid.jqGrid('navGrid', myPager,
{
edit: true,
add: true,
del: true,
search: false,
searchtext: "Buscar",
refreshtext: "",
addtext: "Add",
edittext: "Editar",
deltext: "Delete"
},
{
multipleSearch: true
});


Still no buttons appeared in the navigation pager.



Any idea of what could be wrong?. Thanks a lot!










share|improve this question
























  • Which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= ver4.7?
    – Tony Tomov
    Nov 10 at 23:08















up vote
1
down vote

favorite












I have been trying jqgrid and is fantastic. After searching a lot, I havent found anything related to this topic, and some help would be great.



I need to create dynamically many jqgrid instances from jquery and append them into a list in html.



My problem is that the navGrid pagination div is not showing the add/edit default buttons, neither custom buttons added manually.



Here is the sample code:



function NewgJQGridInstance(houseHoldGridId, gridPlaceholder) {
//Local variables
var myGrid = $("<table>").attr("id", houseHoldGridId);
var myPager = $("<div>").attr("id", houseHoldGridId + "_pager");

function publicInit() {
gridPlaceholder.append(myGrid, myPager);
myGrid.jqGrid({
datatype: "local",
cellsubmit: 'clientArray',
height: 100,
width: 1300,
colModel: [
{ label: 'Cantidad', name: 'cantidad_menaje', index: 'cantidad_menaje', width: 120, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 5 } },
{ label: 'Menaje', name: 'menaje', index: 'menaje', width: 300, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 50, maxlength: 100 } },
{ label: 'Observaciones particulares del menaje', name: 'observaciones_menaje', index: 'observaciones_menaje', width: 750, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 10 } }
],
pager: myPager,
loadonce: true,
//pgbuttons: false,
//pgtext: null,
viewrecords: false,
loadError: function (jqXHR, textStatus, errorThrown) {
alertError('Error al cargar el grid', 'HTTP message body (jqXHR.responseText): ' + 'n' + jqXHR.responseText);
}
});
}
//Initialization
return {
init: publicInit
}
};

var gridDin = new NewgJQGridInstance("jq1234", cellWhereAppendTheGrid);
gridDin.init();


I have tried several ways of showing the navGrid buttons, but none of them worked for the moment.



My first approach was defining the navGrid pager like this:



myGrid.navGrid(myPager,
// the buttons to appear on the toolbar of the grid
{ edit: true, add: true, del: true, search: false, refresh: false, view: false, position: "left", cloneToTop: false },
// options for the Edit Dialog
{
url: 'clientArray',
editCaption: "Edición de elemento",
recreateForm: true,
beforeInitData: function () {
},
checkOnUpdate: false,
checkOnSubmit: false,
closeOnEscape: true,
beforeSubmit: function (postdata, form, oper) {
if (confirm('¿Deseas realmente modificar este registro?')) {
// do something
return [true, ''];
} else {
return [false, '¡La modificación no se ha guardado!'];
}
},
closeAfterEdit: true,
savekey: [true, 13],
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Add Dialog
{
url: 'clientArray',
closeAfterAdd: true,
closeOnEscape: true,
recreateForm: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Delete Dailog
{
url: 'clientArray',
recreateForm: true,
closeOnEscape: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
});


This case was not working, so I tried this other code more simple:



myGrid.jqGrid('navGrid', myPager,
{
edit: true,
add: true,
del: true,
search: false,
searchtext: "Buscar",
refreshtext: "",
addtext: "Add",
edittext: "Editar",
deltext: "Delete"
},
{
multipleSearch: true
});


Still no buttons appeared in the navigation pager.



Any idea of what could be wrong?. Thanks a lot!










share|improve this question
























  • Which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= ver4.7?
    – Tony Tomov
    Nov 10 at 23:08













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have been trying jqgrid and is fantastic. After searching a lot, I havent found anything related to this topic, and some help would be great.



I need to create dynamically many jqgrid instances from jquery and append them into a list in html.



My problem is that the navGrid pagination div is not showing the add/edit default buttons, neither custom buttons added manually.



Here is the sample code:



function NewgJQGridInstance(houseHoldGridId, gridPlaceholder) {
//Local variables
var myGrid = $("<table>").attr("id", houseHoldGridId);
var myPager = $("<div>").attr("id", houseHoldGridId + "_pager");

function publicInit() {
gridPlaceholder.append(myGrid, myPager);
myGrid.jqGrid({
datatype: "local",
cellsubmit: 'clientArray',
height: 100,
width: 1300,
colModel: [
{ label: 'Cantidad', name: 'cantidad_menaje', index: 'cantidad_menaje', width: 120, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 5 } },
{ label: 'Menaje', name: 'menaje', index: 'menaje', width: 300, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 50, maxlength: 100 } },
{ label: 'Observaciones particulares del menaje', name: 'observaciones_menaje', index: 'observaciones_menaje', width: 750, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 10 } }
],
pager: myPager,
loadonce: true,
//pgbuttons: false,
//pgtext: null,
viewrecords: false,
loadError: function (jqXHR, textStatus, errorThrown) {
alertError('Error al cargar el grid', 'HTTP message body (jqXHR.responseText): ' + 'n' + jqXHR.responseText);
}
});
}
//Initialization
return {
init: publicInit
}
};

var gridDin = new NewgJQGridInstance("jq1234", cellWhereAppendTheGrid);
gridDin.init();


I have tried several ways of showing the navGrid buttons, but none of them worked for the moment.



My first approach was defining the navGrid pager like this:



myGrid.navGrid(myPager,
// the buttons to appear on the toolbar of the grid
{ edit: true, add: true, del: true, search: false, refresh: false, view: false, position: "left", cloneToTop: false },
// options for the Edit Dialog
{
url: 'clientArray',
editCaption: "Edición de elemento",
recreateForm: true,
beforeInitData: function () {
},
checkOnUpdate: false,
checkOnSubmit: false,
closeOnEscape: true,
beforeSubmit: function (postdata, form, oper) {
if (confirm('¿Deseas realmente modificar este registro?')) {
// do something
return [true, ''];
} else {
return [false, '¡La modificación no se ha guardado!'];
}
},
closeAfterEdit: true,
savekey: [true, 13],
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Add Dialog
{
url: 'clientArray',
closeAfterAdd: true,
closeOnEscape: true,
recreateForm: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Delete Dailog
{
url: 'clientArray',
recreateForm: true,
closeOnEscape: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
});


This case was not working, so I tried this other code more simple:



myGrid.jqGrid('navGrid', myPager,
{
edit: true,
add: true,
del: true,
search: false,
searchtext: "Buscar",
refreshtext: "",
addtext: "Add",
edittext: "Editar",
deltext: "Delete"
},
{
multipleSearch: true
});


Still no buttons appeared in the navigation pager.



Any idea of what could be wrong?. Thanks a lot!










share|improve this question















I have been trying jqgrid and is fantastic. After searching a lot, I havent found anything related to this topic, and some help would be great.



I need to create dynamically many jqgrid instances from jquery and append them into a list in html.



My problem is that the navGrid pagination div is not showing the add/edit default buttons, neither custom buttons added manually.



Here is the sample code:



function NewgJQGridInstance(houseHoldGridId, gridPlaceholder) {
//Local variables
var myGrid = $("<table>").attr("id", houseHoldGridId);
var myPager = $("<div>").attr("id", houseHoldGridId + "_pager");

function publicInit() {
gridPlaceholder.append(myGrid, myPager);
myGrid.jqGrid({
datatype: "local",
cellsubmit: 'clientArray',
height: 100,
width: 1300,
colModel: [
{ label: 'Cantidad', name: 'cantidad_menaje', index: 'cantidad_menaje', width: 120, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 5 } },
{ label: 'Menaje', name: 'menaje', index: 'menaje', width: 300, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 50, maxlength: 100 } },
{ label: 'Observaciones particulares del menaje', name: 'observaciones_menaje', index: 'observaciones_menaje', width: 750, sortable: false, sorttype: "int", editable: true, editrules: { required: true }, editoptions: { size: 10, maxlength: 10 } }
],
pager: myPager,
loadonce: true,
//pgbuttons: false,
//pgtext: null,
viewrecords: false,
loadError: function (jqXHR, textStatus, errorThrown) {
alertError('Error al cargar el grid', 'HTTP message body (jqXHR.responseText): ' + 'n' + jqXHR.responseText);
}
});
}
//Initialization
return {
init: publicInit
}
};

var gridDin = new NewgJQGridInstance("jq1234", cellWhereAppendTheGrid);
gridDin.init();


I have tried several ways of showing the navGrid buttons, but none of them worked for the moment.



My first approach was defining the navGrid pager like this:



myGrid.navGrid(myPager,
// the buttons to appear on the toolbar of the grid
{ edit: true, add: true, del: true, search: false, refresh: false, view: false, position: "left", cloneToTop: false },
// options for the Edit Dialog
{
url: 'clientArray',
editCaption: "Edición de elemento",
recreateForm: true,
beforeInitData: function () {
},
checkOnUpdate: false,
checkOnSubmit: false,
closeOnEscape: true,
beforeSubmit: function (postdata, form, oper) {
if (confirm('¿Deseas realmente modificar este registro?')) {
// do something
return [true, ''];
} else {
return [false, '¡La modificación no se ha guardado!'];
}
},
closeAfterEdit: true,
savekey: [true, 13],
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Add Dialog
{
url: 'clientArray',
closeAfterAdd: true,
closeOnEscape: true,
recreateForm: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
},
// options for the Delete Dailog
{
url: 'clientArray',
recreateForm: true,
closeOnEscape: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText;
}
});


This case was not working, so I tried this other code more simple:



myGrid.jqGrid('navGrid', myPager,
{
edit: true,
add: true,
del: true,
search: false,
searchtext: "Buscar",
refreshtext: "",
addtext: "Add",
edittext: "Editar",
deltext: "Delete"
},
{
multipleSearch: true
});


Still no buttons appeared in the navigation pager.



Any idea of what could be wrong?. Thanks a lot!







jquery jqgrid jqgrid-asp.net






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 11:37

























asked Nov 10 at 3:27









Barry

143




143












  • Which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= ver4.7?
    – Tony Tomov
    Nov 10 at 23:08


















  • Which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= ver4.7?
    – Tony Tomov
    Nov 10 at 23:08
















Which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= ver4.7?
– Tony Tomov
Nov 10 at 23:08




Which version of jqGrid is used - Guriddo jqGrid, free-jqGrid or jqGrid <= ver4.7?
– Tony Tomov
Nov 10 at 23:08

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235769%2fhow-to-create-multiple-jqgrid-instances-with-jquery%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235769%2fhow-to-create-multiple-jqgrid-instances-with-jquery%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini