gpt4 book ai didi

jqgrid - afterInsertRow : function(ids) method is not executing when I use gridview:true

转载 作者:行者123 更新时间:2023-12-04 15:04:15 26 4
gpt4 key购买 nike

当我设置 网格 View (gridview:true) 在我们的 jqGrid 中提高 jqGrid 的性能,方法如 afterInsertRow ,或不执行其他类似方法。
以下是我的 jgGrid 的代码:

jQuery("#displaylistGrid").jqGrid({
url: contextRoot + '/StandardProxy/displayListService?userRole='+
userRole+'&userName='+userName+'&userId='+userId+
'&duration='+displayDuration+'&wicNo='+wicNo+
'&displayName='+dlDisplayName+'&displayNameArr='+displayNameArr+
'&pointValue='+pValue+'&locationId='+locId+'&locationCode='+
locCode+'&serviceType=forecast',
datatype: 'json',
colNames: ["CM Name", "Display ", "Loc. Pt.","Max. Ben." ,"Display Name",
"Items w/Fcst", "Units", "Sales $", "Profit $", "GP%", "Units",
"Sales $", "Profit $", "GP%","Hidden","Hidden1","Hidden2",
"Start Date and End Date", "Hidden4"],
colModel: [
{ name: "cm_name", index: "cm_name", sorttype: "text", width: 120,
resizable: true },
{ name: "ds_location", index: "ds_location", sorttype: "text", width: 120,
resizable: true },
{ name: "ds_symbol", index: "ds_symbol", sorttype: "text", width: 50,
align: "center", resizable: true },
{ name: "ds_benchMark", index: "ds_benchMark",sorttype: "text", width: 50,
align: "center", resizable: true },
{ name: "ds_name", index: "ds_name", sorttype: "text", width: 230,
resizable: true },
{ name: "ds_ItemFrcst", index: "ds_ItemFrcst",sorttype: "int", width: 60,
align: "center", resizable: true,
unformat: addDemoninatorSortingFormatter },
{ name:"ds_units_promo",index:"ds_units_promo",sorttype:"float",width: 85,
align: "right", unformat : spaceFormatter },
{ name:"ds_sales_promo",index:"ds_sales_promo",sorttype:"float",width: 95,
align: "right", unformat : spaceFormatter },
{ name: "displaylistGrid_ds_profit_promo",
index: "displaylistGrid_ds_profit_promo",
sorttype: "float", width: 95, align: "right",
unformat : spaceFormatter },
{ name:"ds_gp_pct_promo",index:"ds_gp_pct_promo",sorttype:"int",width: 50,
align: "right", unformat : spaceFormatter },
{ name: "ds_units_per_store_week",
index: "ds_units_per_store_week", sorttype:"float",width: 85,
align: "right", unformat : spaceFormatter },
{ name: "ds_sales_per_store_week",
index: "ds_sales_per_store_week",
sorttype: "float", width: 90, align: "right",
unformat : spaceFormatter },
{ name: "ds_profit_per_store_week",
index: "ds_profit_per_store_week",
sorttype: "float", width: 90, align: "right",
unformat : spaceFormatter },
{ name: "ds_gp_pct_per_store_week",
index: "ds_gp_pct_per_store_week",
sorttype: "float", width: 40, align: "right",
unformat : spaceFormatter },
{ name: "hidden1", index: "hidden1", sorttype: "int",
align: "center", hidden: true },
{ name: "hidden2", index: "hidden2", sorttype: "text",
align: "center", hidden: true },
{ name: "hidden3", index: "hidden3", sorttype: "int",
align: "center", hidden: true },
{ name:"forecast_dates",index:"forecast_dates",sorttype: "text",
align: "center", hidden: true },
{ name: "hidden4", index: "hidden4", sorttype: "text",
align: "center", hidden: false }
],
onSelectRow: function(ids){
//checkDisplayDetail();
//setDefaultValuesToTheSortingParams();
var dropDownVal = document.getElementById("displayDetailSelection").value;
var subTabName = document.getElementById("detailSubTabName").value;
if(subTabName=="Active")
dropDownVal = document.getElementById("displayDetailActiveSelection").value;
reLoadDisplayDetailData(ids,'forecast',dropDownVal,subTabName);
},
afterInsertRow : function(ids) { // shows custom tooltip
var customToolTip = jQuery("#displaylistGrid").getCell(ids,'ds_name') +
" -- " + jQuery("#displaylistGrid").getCell(ids,'hidden4');
$("#displaylistGrid").setCell(ids,'ds_name', '','',{title:customToolTip});
},
gridComplete : function(){
if($("#isForecastedSalesGridLoaded").val()=="no"){
$("#jqgh_displaylistGrid_ds_profit_promo").click();
}
else{
$("#isForecastedSalesGridLoaded").val("no");
}
},
onSortCol : function(){
$("#isForecastedSalesGridLoaded").val("yes");
},
width: 983,
rowNum: 999,
height: eval(heightOfDispListGrid()+7),
toolbar: [true, "top"],
viewrecords: true,
treeIcons: {leaf: "ui-icon-document-b"},
treeGrid: true,
treeGridModel: 'nested',
ExpandColumn : 'Description',
ExpandColClick: true,
loadonce:false,
refresh : true,
shrinkToFit: true,
gridview:true,
sortorder:"asc",
sortname:"displaylistGrid_ds_profit_promo"
});

以下是 的代码afterInsertRow 方法:
afterInsertRow : function(ids) {  // shows custom tooltip
var customToolTip = jQuery("#displaylistGrid").getCell(ids,'ds_name') + " -- " +
jQuery("#displaylistGrid").getCell(ids,'hidden4') ;
$("#displaylistGrid").setCell(ids,'ds_name', '','',{title:customToolTip});
},

上述代码用于显示自定义工具提示。请告诉我我做错了什么。

请帮我

谢谢,
DISMGMT

最佳答案

gridview:true的使用感正在跟随。在“gridview”模式下,将创建最多包含的网格 作为字符串 .为了准确地为每个网格行构建一个带有 HTML 标记的子字符串数组,一个人从关于 join('') 的字符串数组中创建一个字符串。然后才创建一个表示网格的 DOM 对象。它提高了性能,不仅因为更好地处理长字符串( join('') ),还因为减少了处理 DOM 对象的工作,这比处理字符串慢得多。

所以我建议你不要使用 afterInsertRow根本。相反,您可以成功地对以下代码执行相同的操作

var myGrid = jQuery("#displaylistGrid");
var ids = myGrid.jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var id=ids[i];
var customToolTip = myGrid.jqGrid('getCell',ids,'ds_name') + " -- " +
myGrid.jqGrid('getCell',ids,'hidden4');
myGrid.jqGrid('setCell',ids,'ds_name', '','',{title:customToolTip});
}

您可以将其包含在 gridComplete 中或 loadComplete .

您将使用 custom formatter 存档的最佳性能为列 ds_name您想要设置自定义工具提示的位置。实现非常简单,因为您的自定义格式化程序将收到 rowObject参数以相同形式的服务器数据行,就像它将从服务器接收一样(作为数组或作为对象)。正确的 hidden4将立即访问(我建议您阅读 this answer 了解更多详细信息)。

更新 : 答案很老了。 jqGrid 提供了许多替代的实现方式,从性能的角度来看要好得多。页面上的每一个变化都跟随浏览器 reflow .所以 setCell的用法在循环中无效。更好的是使用 cellattrrowattr并继续使用 gridview: true the answer中描述了哪些优点.

The answer演示了设置 title 的非常有效的方法在单元格上使用 cellattr而不是 setCell在当前答案中使用。 Another answer提供一个更常见的使用示例 cellattr .要设置网格行的属性可以使用 rowattr打回来。见 the answer对于代码示例。

关于jqgrid - afterInsertRow : function(ids) method is not executing when I use gridview:true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4449317/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com