jQWidgets Forums

jQuery UI Widgets Forums Grid Cell validation not preventing save to database

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 11 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • jr
    Participant

    Hey there first post here, hope its helps me solve my problem.

    I have a grid with validation set up similar to that which I saw in this page. I have a save button that then saves the changes to database. How can make the grid reevaluate the validation and prevent the save from occurring in the DB.

    this is my grid definition:

     $("#jqxgrid").jqxGrid(
                {
                  theme: 'IMS',
                  autoheight: true,
                  pageable: true,
                  pagesize: 50,
                  pagesizeoptions: ['10', '25', '50', '100', '500'],
                  sortable: true,
                  filterable: true,
                  columnsreorder: true,
                  width: "99%",
                  columnsresize: true,
                  editable: true,
                  source: dataAdapter,
                  enabletooltips: true,
                  selectionmode: 'singlerow',
                  columns: [
                      { text: 'CostCenterID', datafield: 'CostCenterID', hidden: true, editable: false},
                      { text: 'Cost Center Description', datafield: 'CostCenterDescription', editable: true, validation: function (cell, value) { return isNotNullorEmpty(cell, value, "A description is required."); } },
                      { text: 'Cost Center Code', datafield: 'CostCenterCode', editable: true, validation: function (cell, value) { return isNotNullorEmpty(cell, value, "A code is required."); } },
                      { text: 'Created', datafield: 'Created', editable: false, cellsformat: 'dd-MMM-yyyy' },
                      { text: 'Created By', datafield: 'CreatedBy', editable: false },
                      { text: 'Last Updated', datafield: 'LastUpdated', editable: false, cellsformat: 'dd-MMM-yyyy' },
                      { text: 'Last Updated By', datafield: 'LastUpdatedBy', editable: false },
                      { text: 'Active', datafield: 'ActiveIndicator', editable: true, columntype: 'checkbox', width: 100 }
                  ]
              });
    $("#ButtonSave").bind('click', function (event) {
    
                    // if update rows id
                    if (_updatedRowIDs.length > 0) {
    
                        var arrInfo = new Array();
                        for (var i = 0; i < _updatedRowIDs.length; i++) {
                            // get data information of the record
                            var recordItem = $('#jqxgrid').jqxGrid('getrowdatabyid', _updatedRowIDs[i]);
                            // add item to array
                            arrInfo.push(recordItem);
                        }
                        SaveRowsInDatabase(arrInfo);
                        $("#NoRowsUpdatedAlert").hide();
    
                    } else {
                        $("#NoRowsUpdatedAlert").show();
                    }
                });

    Thanks for your help


    Peter Stoev
    Keymaster

    Hi jr,

    Cell Validation prevents the Changing of Cell Values which Prevents any further action implemented in the “updaterow”, because “updaterow” will never be raised while the Cell Value is not Changed. I don’t know what’s the purpose of that Save Button. The Synchronization should be implemented in the source object’s updaterow method or at least you should fill your custom Array with updated data there.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.