我通过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>
任何人都可以在重新绑定后向我提供有关如何从网格中访问行的任何指示吗?