Dojo grid.selection.getSelected()。选择一行时的长度
我已经创建了一个dojox.grid.DataGrid,我想对用户选择的行执行一些操作,因此,我发出了一个警报,以获取用户选择的行数 我正在使用: var noofrows=grid.selection.getSelected().length; 警觉(noofrows); 获取用户在网格中选择的行数。 当用户选择一行时,上述语句会向0发出警报,但当用户选择了一行时,该语句会弹出1。 当用户选择多行时,会弹出用户选择的正确行数 选择多行后(弹出正确的结果),当用户选择一行时,会弹出正确的输出,即:1 所以,基本上问题是当用户第一次选择一行时,它会弹出错误的输出(即:0) 以下是网格创建代码:Dojo grid.selection.getSelected()。选择一行时的长度,dojo,dojox.grid.datagrid,Dojo,Dojox.grid.datagrid,我已经创建了一个dojox.grid.DataGrid,我想对用户选择的行执行一些操作,因此,我发出了一个警报,以获取用户选择的行数 我正在使用: var noofrows=grid.selection.getSelected().length; 警觉(noofrows); 获取用户在网格中选择的行数。 当用户选择一行时,上述语句会向0发出警报,但当用户选择了一行时,该语句会弹出1。 当用户选择多行时,会弹出用户选择的正确行数 选择多行后(弹出正确的结果),当用户选择一行时,会弹出正确的输出,即
<table id="AA.FavouritesGrid" dojoType="dojox.grid.DataGrid"
region="center"
jsId="table"
id="table"
store="AAFavouritesStore" style="font-size:30px;width:100%;padding:0px;display:0px;">
<thead>
<tr>
<%
String userCode ="";
userCode = request.getUserPrincipal().getName();
try {
Map<String,String> columnNameLabelMap=model.getDynamicNameLabelmap("Favourites", userCode, locale);
// Loop round columns ordered by user
for (Map.Entry<String, String> entry : columnNameLabelMap.entrySet()){
int width = columnDataById.get(entry.getKey()).getWidth();
columnDataById.remove(entry.getKey());
%>
<th field=<%=entry.getKey() %> width="<%=width%>" height="22px" nowrap="nowrap"><%=entry.getValue()%></th>
<%
}
} catch (Exception e) {
System.out.println(e);
}
// Present any left over columns in default order
for (ColumnData entry : columnDataById.values()){
%>
<th field=<%=entry.getId() %> width="<%=entry.getWidth()%>" height="22px" nowrap="nowrap"><%=entry.getName()%></th>
<%
}
%>
<th field="path" hidden="true"></th>
<th field="underwritingYear" hidden="true" ></th>
<th field="lpRCTLobDesc" hidden="true" ></th>
<th field="lpRCTLob" hidden="true" ></th>
</tr>
</thead>
</table>
favContextMenu=dojo.connect(dijit.byId(“AA.favoritesgrid”)、“onCellContextMenu”、favoritesgridonContextmenu)
功能收藏夹RidonContextMenu(e){
警报(table.selection.getSelected().length);
}
请帮忙解决这个问题
谢谢请尝试以下两种方法获取所选项目和项目
var e = dijit.byId("addressMapStoreGrid");
if (e.focus.rowIndex < 0) {
alert('Please select one row!');
return;
}
问题不清楚,请编辑相同的内容,以便我们了解您的意思。编辑..请帮助解决问题请发布一些代码,以便我们了解错误的位置。如果您需要更多信息,请告诉我我发现了一些有趣的内容,实际上它们是两件事:用户第一次单击(左键单击)在一行上单击鼠标右键,返回正确的输出(即:1)。如果用户直接右键单击一行,则返回错误的输出(即:0)。如何解决?感谢您的提示帮助…我尝试了上述代码,但问题仍然存在。实际上,它们是两件事:用户先单击(左键单击)一行,然后右键单击,返回正确的输出(即:1)。如果用户直接右键单击一行,则返回错误的输出(即:0)。如何解决这个问题???@user2927223这是因为当时没有选择该行,所以不能使用
.getSelected()
方法。当用户右键单击时,可以首先选择行。
var items = grid.selection.getSelected();