Flexgrid validation on cell edit ended

Posted by: deepak.dubey on 18 June 2020, 3:56 am EST

  • Posted 18 June 2020, 3:56 am EST

    Hi,

    I am creating a separate JS file in vue to validation of grid cell values.

    So I am using getError method of grid collection.

    Now I faced some issue with this.

    1. It is render all column on every change and I want only for activeEditor cell.
    2. cell should allow to edit other cell also while current cell have wrong value , means user should not restrict to put write values.

    Here is my code

    this.grid.collectionView.getError = function(item, prop,s) {

    console.log(item);

    switch (prop) {

    case ‘planType’:

    break;

    case ‘planName’:

    if(item.planName.length > 100){

    return “Plan Name should not exceed 200 Characters”;

    }

    break;

    case ‘planID’:

    if(item.planID.length > 50){

    return “Plan ID should not exceed 200 Characters”;

    }

    break;

    case ‘ECS_ID’:

    if(isNaN(parseFloat(item.ECS_ID)) && isFinite(item.ECS_ID)){

    return “ECS Id should be number”;

    }

    break;

    case ‘conversion’:

    if(item.conversion == “”){

    return “Conversion field at Plan Level should be Null or >0.”

    }

    break;

    case ‘trancheExist’:

    break;

    case ‘analystComment’:

    if(item.analystComment.length > 100){

    return “Message should trigger when Analyst comment at Plan Level exceeds 500 characters.”;

    }

    break;

    case ‘Oustanding’:

    if (item.Oustanding < 0) {

    return ‘Outstanding at the end of the period should not be < 0’;

    }

    break;

                case 'transactions.downloads':
                  if (item.transactions.downloads < 0) {
                    return 'Downloads cannot be negative';
                  }
                  break;
                case 'transactions.sales':
                  if (item.transactions.sales < 0) {
                    return 'Sales cannot be negative';
                  }
                  break;        
                case 'transactions.expenses':
                  if (item.transactions.expenses < 0) {
                    return 'Expenses cannot be negative';
                  }
                  break;
              }
              return null; // no errors
            }
    

    Regards

    Deepak Dubey

  • Posted 19 June 2020, 4:18 am EST

    Hi Deepak,

    The getError method works for each cell and we cannot prevent this. So, only setting the error for the currently editing cell is not possible.

    Regarding the 2nd issue, the validateEdits property of the FlexGrid can be used in this requirement. This property determines whether the user can exit the edit mode if there is any error in the current cell being edited. Set its value to false and you will be able to exit the edit mode.

    API: https://www.grapecity.com/wijmo/api/classes/wijmo_grid.flexgrid.html#validateedits

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels