我正在尝试将showlink用于第二个域类,称为location,我将其嵌套在我的第一个域类中。我想要做的是,当我点击位置栏中网格中的数据时,我想把我带到我的show.gsp位置。
我遇到的问题是它确实将我带到了显示页面的位置,但是它采用了它所在的行的索引并试图指向该节目。例如,在第7行中,我单击位置列中的链接。虽然我的位置列表中的位置索引是2,但它指向7这是行索引,并显示位置列表中索引7处的位置的详细信息。
我想弄清楚的是如何更改我的showaction线,以便当我点击指向位置的超链接时它指向正确的位置。
我正在使用jqgrid 3.8.0.1
以下是我的jqgrid javascript的内容。
<script type="text/javascript">
$(document).ready(function() {//code goes here
jQuery("#allRoster").jqGrid({
heigth: 'auto', //height of the grid
width: '1000', // width of the grid
caption: 'Roster List', //Title for the grid
url: 'listAllRoster', //loaction in where the data for the grid is comiing from. The controller you use to initialize the grid data.
editurl:'editAllRoster', //same as the url command, points to the controller editAllRoster to tell the edit column what to do when editting the rows.
datatype: "json", //the type of data processing through the grid.
colNames: ['','Name', 'Position', 'Department', 'Location'], // The column titles you want to use for the grid
colModel: [ //The parameters for the data going through each column.
//This empty column is a column that holds both the edit and delete button.
{name:'actions', index:'actions', search:false, sortable:false, title:false, editable:false, required:false, sortable:false, width:"20",
formatter: 'actions', hidden:false, formatoptions: {
keys: true, editbutton: true, delbutton: true}
},
{name:'name', width:200,editable:false, sortable: true, formatter:'showlink',formatoptions: {baseLinkUrl:'../roster/', showAction:'show'},title:false},
{name:'position', width:200, editable:true},
{name:'department', width:200, editable:true},
{name:'location', width:200,editable:false ,title:false, formatter: 'showlink', formatoptions: {baseLinkUrl: '../location/' ,showAction:'show'}}
],
rowNum:10, //amount of rows you want to start off when the grid is called
rowList:[10,20,40,60], //the size of the number of rows you want to hold
gridview: true, //allows you to see the grid, not sure if absolutley neccessary
viewrecords: true, //same for gridview
sortname: 'name',//when grid is inialized what you want the rows to be sorted by.
sortorder: "asc",//if the sorting order from sort name are in asceding order or not.
autowidth:true, //the width of the column holding the data to be auto.
forceFit:true,
shrinkToFit: true,
pager: '#rosterAllPager',
scrollOffset:0,
gridComplete: function() {
}
});
我遇到问题的一行就是这一行:
{name:'location', width:200,editable:false ,title:false, formatter: 'showlink', formatoptions: {baseLinkUrl: '../location/' ,showAction:'show'}}
这就是我所看到的。 Roster Grid
在我的网格中,第1行和第2行具有相同的位置,但是当我点击第二行时,我得到的位置是纽约而不是洛杉矶。此外,如果我尝试点击第三行,我会得到一个空白屏幕,因为第三个位置不存在。
这是位置列表的图像。 List of Locations