我已经通过 Jquery 编辑了数据并反弹了 Telerik MVC Grid。事情是我需要访问“新”行,或者改写重新绑定过程后生成的行。出于某种原因,我的 Jquery 函数从网格中读取旧数据,即重新绑定过程之前的数据。
<script type="text/javascript">
var categoryID;
var subCategoryID;
var categoryForSubCategoryId;
function onChangeSubCategories(e) {
var url = '/SubCategory/FindSubCategoryIdByName/';
$.ajax({
type: 'GET',
data: { name: e.value },
dataType: 'html',
url: url,
success: function(data) {
var ids = data.split('###');
subCategoryID = ids[0];
categoryID = ids[1];
var subCategoryGrid = $('#SubCategoryGrid').data('tGrid');
subCategoryGrid.rebind();
var productGrid = $('#ProductGrid').data('tGrid');
productGrid.rebind();
$('#CategoryGrid tr').each(function () {
var tr = this;
if (tr.cells[0].innerHTML == categoryID) {
$(this).toggleClass('t-state-selected');
}
else if ($(this).hasClass('t-state-selected')) {
$(this).toggleClass('t-state-selected');
}
});
$('#SubCategoryGrid tr').each(function () {
//TODO: every row here is the old data
var tr = this;
if (tr.cells[0].innerHTML == subCategoryID) {
$(this).toggleClass('t-state-selected');
}
else if ($(this).hasClass('t-state-selected')) {
$(this).toggleClass('t-state-selected');
}
});
}
});
}
</script>
任何人都可以告诉我如何在重新绑定后从网格中访问行吗?