Wijmo UI for the Web
beforeCellUpdate Event
The jQuery.Event object.
The data with this event.
The beforeCellUpdate event handler is a function that is called before the cell is updated with new or user-entered data. This event is cancellable if the editingMode options is set to "cell". There are many instances where this event is helpful, such as when you need to check a cell's value before the update occurs or when you need to apply an alert message based on the cell's value.
Syntax
Javascript (Usage) 
$(function () {
    // Set beforeCellUpdate event handler function
    $(".selector").wijgrid({
        beforeCellUpdate : function (e, args) {
     
        }
    });
});
Javascript (Specification) 
beforeCellUpdate = function ( 
   e : Object,
   args : IBeforeCellUpdateEventArgs
) { };

Parameters

e
The jQuery.Event object.
args
The data with this event.
Example
// In this sample, you use args.value to check the year that the user enters in the "Acquired" column.
// If it's less than 1990 or greater than the current year, then the event handler will return false to cancel updating and show the user an alert message.
$("#element").wijgrid({
    beforeCellUpdate: function(e, args) {
        switch (args.cell.column().dataKey) { 
            case "Acquired":
                var $editor = args.cell.container().find("input"),
                    value = $editor.wijinputnumber("getValue"),
                    curYear = new Date().getFullYear();
                if (value < 1990 || value > curYear) {
                    $editor.addClass("ui-state-error");
                    alert("value must be between 1990 and " + curYear);
                    $editor.focus();
                    return false; 
                }
                args.value = value; 
                break;
        }
    }
});
Remarks
You can bind to the event either by type or by name. Bind to the event by name: $("#element").wijgrid({ beforeCellUpdate: function (e, args) { // some code here }}); Bind to the event by type: $("#element").bind("wijgridbeforecellupdate", function (e, args) { // some code here });

See Also

Reference

options type
wijgrid jQuery Widget

 

 


© 2013 All Rights Reserved.

Send comments on this topic.