Hellos Guys!
就像标题一样,我试图在加载bootgrid期间检查某些行,但是我被卡在每一行被选择的地方,而不是应该被选择的那一行。
到目前为止,这是我的代码。
$("#agents-grid").bootgrid({
ajax: true,
post: function () {
return {
filterProducerCode: $("#filter-producer-code").val(),
filterProducerName: $("#filter-producer-name").val()
}
},
url: "GridProducersAsCaptured",
selection: true,
multiSelect: true,
rowSelect: true,
keepSelection: true,
templates: {
search: ""
},
converters: {
money: {
from: function (value) { return unmoney(value) },
to: function (value) { return money(value) }
}
},
formatters: {
"link": function (column, row) {
return "<a href=\"#\">" + column.id + ": " + row.id + "</a>"
}
},
rowCount: [10, 25, 50, -1],
labels: {
infos: "<span style='font-weight:bold;'>Showing {{ctx.start}} to {{ctx.end}} of {{ctx.total}} agents.</span>",
noResults: "No agents found.",
loading: 'Loading agents...'
}
}).on("selected.rs.jquery.bootgrid", function (e) {
if ($("#agents-grid").bootgrid("getSelectedRows").length > 0)
$("#selected-agents").text("( " + $("#agents-grid").bootgrid("getSelectedRows").length + " selected )")
else $("#selected-agents").text("")
}).on("deselected.rs.jquery.bootgrid", function (e) {
if ($("#agents-grid").bootgrid("getSelectedRows").length > 0)
$("#selected-agents").text("( " + $("#agents-grid").bootgrid("getSelectedRows").length + " selected )")
else $("#selected-agents").text("")
}).on("loaded.rs.jquery.bootgrid", function (e) {
var rowIds = [];
$('#agents-grid > tbody > tr').each(function (i, row) {
//var tds = $(row).find("td").eq(3).find(":text").val();
var tds = $(row).find("td").eq(2).html();
var tds2 = $(row).find("td").eq(1).html();
var tds3 = $(row).find("td").eq(3).html();
if (tds3 == "true") {
//$(row).find('input').attr('checked', 'checked')
//this.selectedRows.push(tds2);
rowIds.push(tds2);
}
})
$("#agents-grid").bootgrid("select").push(rowIds)
//$("#agents-grid").bootgrid("select"(rowIds))
})
我正在标识选定的行,但将其发送到“ $(”#agents-grid“)。bootgrid(” select“(rowIds))”的那一刻,该函数将其接收为空,并且在执行该函数之前,rowIds已满以及我要查找的特定行。
任何帮助将不胜感激!谢谢!
答案 0 :(得分:0)
在我的代码上发现了问题!
问题是:
$("#agents-grid").bootgrid("select").push(rowIds)
解决方法是:
$("#agents-grid").bootgrid("select", rowIds)