How to set pending changes dynamically

5 replies. Last post: September 24, 2012 6:46 AM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
T LusbyMember

I have a grid with a column named "Sort Order".  The user can make a change to this text field.  When the field is changed, we need to validate it.  On the OnAfterExitEditMode, we do the validation of the cell.  Depending on this value, I may have to change other rows.

At the bottom of the grid is shows the correct pending change(s); however, when I try to view them. I get an error in 305000803.js on " if

(vd0b48.substring(0,1)=="/" ||vd0b48.substring(0,1)=="." ||

"

vd0b48 is undefined.

 

If I don't select this and try to apply my changes I get a communication error.

Here is the aspx code:

function OnCellValidate(controlId, tblName, editObject) {
            AddToCounter();
            var grid = ISGetObject(controlId);

            var rootTable = grid.RootTable;

            if (editObject != null) {
                var cell = wgGetCellByElement(editObject.cellElement);
                if (cell.GetRow().Type != "FilterRow") {

                    var cellObject = editObject.ToCellObject();

                    var selectedObject = grid.GetSelectedObject();
                    var selectedRow = selectedObject.ToRowObject(); // return WebGridRow object

                    var colName = cell.Name;
                    var row = cell.Row;

                    var OrigValue = Trim(cell.OldText);
                    var NewValue = Trim(cell.Value);

                    switch (colName) {
                        case "SortOrder":
                            if (controlId == DetailColumnGrid) {
                                ChangeSortOrder(controlId, NewValue);
                                row.GetCells().GetNamedItem(colName).SetText(NewValue, true);
                                row.GetCells().GetNamedItem(colName).SetValue(NewValue);
                            }
                            break;
                        default:
                            break;
                    }

                    if (OrigValue != NewValue && selectedRow.Type != "NewRow") {
                        cellObject.CellElement.style.fontWeight = "bold"
                        selectedRow.SetDataChanged();
                        grid.MarkEdit();
                    }
                }
            }
            return true;
        }

        function ChangeSortOrder(controlId, OrderNum) {
            var grd = ISGetObject(controlId);
            if (grd == null) return;
            var rows = grd.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE).getElementsByTagName("tr");
            // iterate through all rows
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].type == "Record") {

                    if (parseInt(grd.GetRootTable().GetRow(i).GetCells().GetNamedItem("SortOrder").Value) >= parseInt(OrderNum)) {
                        //alert(parseInt(grd.GetRootTable().GetRow(i).GetCells().GetNamedItem("SortOrder").Value));
                        var newVal = parseInt(grd.GetRootTable().GetRow(i).GetCells().GetNamedItem("SortOrder").Value) + 1;
                        newVal = newVal.toString();
                        grd.GetRootTable().GetRow(i).GetCells().GetNamedItem("SortOrder").SetText(newVal, true);
                        grd.GetRootTable().GetRow(i).GetCells().GetNamedItem("SortOrder").SetValue(newVal, true);
                        grd.GetRootTable().GetRow(i).SetDataChanged();                  
                        grd.GetRootTable().GetRow(i).AddPendingChanges();                        
                    }
                }
            }
        }

 

All times are GMT -5. The time now is 4:43 PM.
Previous Next