I need to load some dynamic html when a user click on a link in a jqGrid.
here is my definition
function loadUserAdministrationList() {
jQuery("#userlist").jqGrid({
url: '/Administration/GetData/',
datatype: 'json',
mtype: 'GET',
colNames: ['Username', 'Prénom', 'Nom', 'Courriel'],
colModel: [{ name: 'Username', index: 'Username', width: 300, align: 'left',
edittype: 'select', formatter: 'showlink',
formatoptions: { baseLinkUrl: '/Administration/ModifyUser'} },
{ name: 'Prénom', index: 'Firstname', width: 300, align: 'left' },
{ name: 'Nom', index: 'Lastname', width: 300, align: 'left' },
{ name: 'Courriel', index: 'Email', width: 300, align: 'left'}],
pager: jQuery('#userlistpager'),
rowNum: 20,
rowList: [5, 10, 20, 50],
sortname: 'Firstname',
sortorder: "asc",
height:600,
viewrecords: true,
imgpath: '/Public/css/theme/custom/images',
caption: '',
loadtext: 'Chargement des utilisateurs...'
}).navGrid('#userlistpager',
{ search: true, edit: false, add: false, del: false },
{}, // default settings for edit
{}, // default settings for add
{}, // default settings for delete
{ closeOnEscape: true, multipleSearch: true,
closeAfterSearch: true }, //search options
{}
);
};
as you can see i would like to load a modification form.
How can i tell jqGrid to do an ajax call on the click of showLink ?
Thanks
A possible solution could looks like following:
edittype: 'select'andalign: 'left'and consider to addtitle: falseinstead to remove displaying of the ToolTip on hover a cell with the mouse.formatoptionswhich containformatter: 'showlink'to following:formatoptions: { baseLinkUrl: 'javascript:', showAction: "MyBase.GetAndShowUserData(jQuery('#userlist'),'#myDiv','", addParam: "');" }. jqGrid will constructhrefattribute of<a>element like following:href="javascript:MyBase.GetAndShowUserData(jQuery('#userlist'),'#userDetails','?id=rowId');"whererowIdwill be the id of the corresponding grid row.MyBase.GetAndShowUserDatalike following:(In the code below we use global
MyBaseonly for namespacing)I suppose here, that on your page there are a
<div>or other element withid="userDetails"likeand the function
MyBase.GetAndShowUserDatawill make an ajax call and fill the results inside the<div id="userDetails"></div>. The code inside ofMyBase.GetAndShowUserDatais a raw template only. I wanted only to show how you can access the data from the grid.