- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 View 模型中显示订单的订单详细信息。点击订单并view
寻呼机按钮传递 orderID
。使用orderID
,我正在另一个 local json array
中搜索。我正在制作一个包含搜索结果数组值的表,并将其添加为已在 View 模型中使用的行之间的新行,如下图所示。
(从上图中,我着色边框的行是新创建的行。其他行默认由jqGrid创建。)
我与其他行一样创建成功。但是,在单击 View 模型中的“查看下一个或上一个记录”按钮时,它会带来一些麻烦。请参见下图,
(不同行的表列值重复附加在单行中)
在此我浏览记录 8
次通过下一个 ( #nData
) 和上一个 ( #pData
) 按钮。这样做时,左侧 <td>
我的客户行的文本“订单详情”和下一个自动生成的 row's
(总计)右侧<td>
的文字重复8
次。我每次单击下一个或上一个,它都会在我的自定义行之后附加新行。
这是我的代码,
var myData2 = <?php echo json_encode($oParticularResult) ?>;
//Here I'm adding custom row
var showIdRow = function ($form) {
var $this = $(this),
rowid = $this.jqGrid("getGridParam", "selrow");
var addHTML = '<tr class="FormData" id="trv_particulars"><td class="CaptionTD form-view-label ui-widget-content"
width="30%"><b>Order Particulars</b></td>';
addHTML += '<td class="DataTD form-view-data ui-helper-reset ui-widget-content" id="v_tot"><span>';
addHTML += "<table border='2px'><thead><tr><td>Sl.No.</td><td>Particulars
Name</td><td>Quantity</td><td>Amount</td></tr></thead><tbody>";
var count = 1;
for (i in myData2)
{
if(myData2[i].orderID == rowid)
{
addHTML += "<tr><td>"+count+"</td><td>"+myData2[i].proName+"</td><td>"+myData2[i].proQuantity+"</td><td>"+myData2
[i].proPrice+"</td></tr>";
count++;
}
}
$(addHTML).insertAfter('#trv_order_dt');
};
$(function () {
var myData = <?php echo json_encode($orderResult) ?>;
var getCellVal;
var sel_id;
$("#orderGrid").jqGrid({
caption:'Order List',
datatype:'local',
data:myData,
mtype:'POST',
width:777,
rowNum:10,
height:100,
sortorder:'asc',
rowList:[10,20,30],
rownumbers:true,
viewrecords:true,
gridview:false,
autoencode:true,
loadonce:true,
pager:'#orderPager',
sortname:'orderID',
editurl:'<?php echo $this->action('editStatus'); ?>',
colNames:['Order Number','Customer Name','Date', 'Total', 'Paid','Balance'],
//cmTemplate:{editable:true, editrules: {required:true}},
colModel:[
{ name:'orderID', key:true, width:30 },
{ name: 'custName', index: 'custName', width:60 },
{ name: 'order_dt', index: 'order_dt', width:60 },
{ name: 'tot', index: 'tot', width:60 },
{ name: 'amount', index: 'amount', width:60 },
{ name: 'bal', index: 'bal', width:60 }],
}).navGrid("#orderPager",
{add:false, edit:false, view:true, del:false, search:true, refresh:true },
{},//edit
{jqModal: true, viewPagerButtons: true, checkOnUpdate:true, savekey: [true,13], navkeys: [false,38,40], checkOnSubmit :
true, reloadAfterSubmit:false, closeOnEscape:true, closeAfterEdit: true,width:600, height:300}, //add
{jqModal: true, reloadAfterSubmit:true, closeOnEscape: true,width:600, height:300}, //del
{jqModal: true, closeAfterSearch: true, closeOnEscape: true, multipleSearch: true, multipleGroup:false, showQuery: true,
overlay: true, recreateFilter: true,width:600, height:300 }, //search
{jqModal: true, closeOnEscape: true, width:500,
recreateForm: true,
afterclickPgButtons: showIdRow,
beforeShowForm: showIdRow
} //view
);
});
谁能指出我错过的地方?
我想配置subgrid
,使用我的local data
myData2
就像上面的情况一样。如果订单ID为myData
(主网格的本地 json 数组)和 myData2
(子网格的本地 json 数组)相同,显示那些 myData2
下面的记录到父网格行。我认为所有网格都是子网格概念,已经配置得一样。但我找不到任何正确的文档或示例。请提供任何链接以按照上述配置子网格。
解决方案:
我解决了我的问题。每次我们单击该模型中的下一个或上一个按钮时,该 View 模型都会刷新。因为,我用了recreateform:true
我正在调用 showIdRow
上afterclickPgButtons
和beforeShowForm
.
我认为它不会将我手动添加的行视为表单值之一。因为在创建表单时,内容是从 myData
加载的。 (本网格数据来源)。因此,当我浏览下一个或上一个按钮时,recreateform
正在为其他行工作并且 afterclickPgButtons' and 'beforeShowForm
正在调用showIdRow
并将新行添加到下面已创建的行中。
因此,我决定删除先前创建的新行,同时追加新行。我已经将自定义行 ID 指定为 trv_particulars
。所以,我像这样使用了我的代码,
.
.
$('#tvr_Particulars').remove(); // remove previously created custome row using row ID
$('#trv_order_dt').after(addHTML);
.
.
现在它在我的场景中工作正常。但@Oleg 在下面answer 中提供了替代和最佳解决方案。 。感谢@Oleg 花时间为我的问题创建另一个可能的解决方案。
最佳答案
我发现你的问题很有趣,所以我创建了 the demo这表明了此类要求的可能实现。 View 的结果如下图所示:
对实现的一些评论。首先,我使用了网格的输入数据,其中包含在 View 中创建“订单详细信息”(“订单详情”)所需的详细信息:
var mydata = [
{ id: "1", invdate: "2007-10-21", name: "test", note: "3note", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00",
subgrid: [{no: "1", amount: "750"}, {no: "2", amount: "750"}, {no: "3", amount: "600"}, {no: "4", amount: "900"}] },
{ id: "2", invdate: "2007-10-22", name: "test2", note: "3note2", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00",
subgrid: [{no: "1", amount: "750"}, {no: "2", amount: "600"}, {no: "3", amount: "900"}] },
...
];
subgrid
每个项目的属性都包含信息。
接下来,我在 View 表单的表中插入带有“订单详细信息”(“订单详情”)的自定义行,位于包含“关闭”列信息的行之后。我使用代码
$("#trv_closed").after('<tr class="FormData">' +
'<td class="CaptionTD form-view-label ui-widget-content" width="40%"><b>Order Particulars</b></td>' +
'<td class="DataTD form-view-data ui-helper-reset ui-widget-content"><div style="width:100%;height:100%">' +
'<table id="mysubgrid"><tr><td>' +
'</td></tr></table>' +
'</div></td></tr>');
在行"#trv_closed"
之后添加行(行的 id 将根据“关闭”列的名称构造)。
然后可以通过不同的方式获取当前显示行的rowid。第一种方法是获取当前选定的行 $this.jqGrid("getGridParam", "selrow")
。另一种方法:可以从包含 <input>
的隐藏列中获取信息。具有 rowid 的元素。可以解决<input>
元素由id="id_g"
( $("#id_g").val()
) 或通过 name="id"
($form.find("input[name=id]").val()
)。我用$("#id_g").val()
在我的代码中。
现在可以获得subgrid
使用 getLocalRow
选定行的属性(因为我们使用 datatype: "local"
):
var localRowData = $this.jqGrid("getLocalRow", rowid);
// localRowData.subgrid contains the required data
所以完整的代码是
$("#list").jqGrid("navGrid", "#pager", {edit: false, add: false, del: false, view: true, search: false}, {}, {}, {}, {}, {
recreateForm: true,
afterclickPgButtons: function (buttonName, $form, pos) {
showDetails.call(this, $form);
},
beforeShowForm: showDetails,
labelswidth: '40%'
});
其中函数showDetails
定义如下
var showDetails = function ($form) {
var $this = $(this),
rowid1 = $this.jqGrid("getGridParam", "selrow"),
rowid = $("#id_g").val(), //id2 = $form.find("input[name=id]").val(),
localRowData = $this.jqGrid("getLocalRow", rowid);
if (isClosed === "Yes") {
$("#trv_id").show();
}
if ($("#mysubgrid").length === 0) {
// if not in afterclickPgButtons for example
$("#trv_closed").after('<tr class="FormData">' +
'<td class="CaptionTD form-view-label ui-widget-content" width="40%"><b>Order Particulars</b></td>' +
'<td class="DataTD form-view-data ui-helper-reset ui-widget-content"><div style="width:100%;height:100%">' +
'<table id="mysubgrid"><tr><td>' +
'</td></tr></table>' +
'</div></td></tr>');
$("#mysubgrid").jqGrid({
datatype: "local",
data: localRowData.subgrid,
colNames: ["#", "Amount"],
colModel: [
{name: "no", width: 40, sorttype: "integer"},
{name: "amount", width: 70, sorttype: "integer"}
],
idPrefix: "s",
sortname: "no",
rowNum: 1000,
height: "auto"
});
} else {
// update $("#mysubgrid") with new data
$("#mysubgrid").jqGrid("clearGridData")
.jqGrid("setGridParam", {data: localRowData.subgrid})
.trigger("reloadGrid");
}
};
关于jquery - 在 jqGrid 的 View 模型中添加自定义行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23040186/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!