Howdy...
I'm loading a grid with data on demand (via a combination of combobox selections) and the checked status is not being cleared when new data is loaded. My code:
$('#dgExample').datagrid({
url: '/admin/ajax.aspx?a=getFiltered&r=' + $('#Some_Id').val() + '&i=' + fooId,
onLoadSuccess: function (data) {
var stringOfIDs = "";
for (i = 0; i < data.rows.length; ++i) {
if (data.rows[i]['Selected'] == 1) {
$(this).datagrid('checkRow', i);
if (stringOfIDs.length > 0) { stringOfIDs+= ','; }
stringOfIDs+= data.rows[i]['id'];
} else {
$(this).datagrid('uncheckRow', i);
}
}
$('#IDList').val(stringOfIDs);
}
});
I'm returning "Selected" as a 1/0 in the JSON, and iterating over that checking and unchecking the rows as needed. At first I tried just looking for the "1"s and selecting the rows, but that wasn't unchecking and "existing" rows. Shouldn't the selected/checked state be cleared each time you load data into the data grid?
Also - is there anyway to have the load event look for "Selected" as a name / value pair and check the checkbox automatically ?