Hi All,
How do I bind/unbind the "AfterCellUpdate" event on UltraWebGrid in the client-side? I have a requirement to iterate through the grid rows and update values in other columns based on business rules. Whenever I update the grid cell, the event calls itself and it goes in a recursive loop. I would like to avoid this. Any help on this would be highly appreciated!
Thanks
Hello Ram,
Your code seems fine. Which is the version of the grid that you are using? How long time it takes to iterate through the rows ? Is there any difference about the performance with different browsers?
Thanks.
Hello Rado,
Were you able to look into the issue? I have copied the JavaScript code for your reference.
Thanks!
Here is the javascript code -
<script language="javascript" type="text/javascript">
var _CellId = null;
var _HeaderDeleteHandled = false;
var _IsProject = false;
var _ProjectId = -1;
var _IsDeleteChecked = false;
var _IsReviewedChecked = false;
var _IsEngagementItem = false;
var _ItemId = -1;
var _IsColorClarityItem = false;
var _SkipAfterCellUpdate = false;
function selectDeselectAllDelete() {
var grid = igtbl_getGridById('grdResult');
var chkAll = document.getElementById("chkAll").checked;
_SkipAfterCellUpdate = true;
for (i = 0; i < grid.Rows.length; ++i) {
var row = grid.Rows.getRow(i);
row.getCellFromKey('IsDeleted').setValue(chkAll);
}
_SkipAfterCellUpdate = false;
return;
function selectDeselectAllReview() {
var chkAll = document.getElementById("chkAllReview").checked;
row.getCellFromKey('IsReviewed').setValue(chkAll);
if (!chkAll) {
row.getCellFromKey("ReviewDate").setValue("");
else {
var today = new Date()
var month = today.getMonth() + 1
var day = today.getDate()
var year = today.getFullYear()
var date = (month + "/" + day + "/" + year)
row.getCellFromKey("ReviewDate").setValue(date);
function AfterCellUpdate(gridId, cellId) {
if (!_SkipAfterCellUpdate) {
if (_CellId == null) {
_CellId = cellId;
//dirty page check
var cell = igtbl_getCellById(cellId);
var oldValue = cell._oldValue;
var newValue = cell.getValue();
if (oldValue != newValue) {
document.getElementById('hdnIsChanged').value = "1";
var row = igtbl_getRowById(cellId);
//get the column values
_IsProject = (row.getCellFromKey("IsProjRow").getValue() == "True");
_ProjectId = row.getCellFromKey("ProjectID").getValue();
_IsDeleteChecked = Boolean(row.getCellFromKey("IsDeleted").getValue());
_IsReviewedChecked = Boolean(row.getCellFromKey("IsReviewed").getValue());
if (!_IsProject) {
_IsEngagementItem = Boolean(row.getCellFromKey('IsEngParentItem').getValue());
_ItemId = row.getCellFromKey("AA_Item_ID").getValue();
if (!_IsEngagementItem) {
_IsColorClarityItem = Boolean(row.getCellFromKey('IsColorClarityItem').getValue());
_HeaderDeleteHandled = false;
var columnName = cell.Column.Key;
if (columnName == 'ReviewDate') return;
if (columnName == 'IsReviewed') {
//uncheck the header checkbox if any review checkbox is unchecked
if (!_IsReviewedChecked) {
document.getElementById("chkAllReview").checked = false;
//set the review date column
else if (columnName == 'IsDeleted') {
//uncheck the header checkbox if any delete checkbox is unchecked
if (!_HeaderDeleteHandled) {
if (!_IsDeleteChecked) {
document.getElementById("chkAll").checked = false;
_HeaderDeleteHandled = true;
var row = null;
if (_IsProject) {
for (i = 0; i < grid.Rows.length; i++) {
row = grid.Rows.getRow(i);
var projectId = row.getCellFromKey("ProjectID").getValue();
var isDeleteChecked = row.getCellFromKey("IsDeleted").getValue();
if (projectId == _ProjectId && isDeleteChecked != _IsDeleteChecked) {
row.getCellFromKey('IsDeleted').setValue(_IsDeleteChecked);
else if (_IsEngagementItem) {
var isProject = (row.getCellFromKey("IsProjRow").getValue() == "True");
var itemId = row.getCellFromKey("AA_Item_ID").getValue();
//if an engagement item is unchecked, uncheck the Project
if (isProject && projectId == _ProjectId && isDeleteChecked != _IsDeleteChecked) {
row.getCellFromKey('IsDeleted').setValue(!isDeleteChecked);
if (itemId == _ItemId && isDeleteChecked != _IsDeleteChecked) {
else if (_IsColorClarityItem) {
//if a C/C item is unchecked, uncheck the Project and Parent Engagement Item
var isEngagementItem = Boolean(row.getCellFromKey('IsEngParentItem').getValue());
if (isEngagementItem && itemId == _ItemId && isDeleteChecked != _IsDeleteChecked) {
_CellId = null;
</script>
Hey Ram,
Can you paste your javascript code used to iterate through the rows please?
I have around 100 rows in the grid. Checking all the items for the first time takes a lot of time, subsequent checks/unchecks are little faster.
Can something be done for this?