Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Custom validation, grid cells empty
posted

Hi - I am working with Angular 2, Typescript and Node.js. I am working on a custom validation (not using the validator feature). The custom validator works on a per row basis and it checks right to left that the values in each of the right cells are greater than the ones on the left for the same row.

 

My validation does something like this:

 

    private onRowValidating(ui: any): boolean {

 

        let rowId = ui.rowAdding && ui.columnKey === blah ? ui.value : ui.rowID;

        this.log.info('Row validating', rowId);

        let isValid = true;

 

        for (let i = this.gridData.columnDefs.length; i > 0; i--) {

            let columnIndex = i - 1;

            let columnKey = this.gridData.columnDefs[columnIndex].key;

            console.log(columnKey);

 

            let cellValue = jQuery('#' + this.id).igGrid('getCellValue', rowId, columnKey);

 

            // "if cellValue is truthy," where "truthy" is a non-zero, non-null, non-undefined,

            // non - false, non - empty - string value

            if (!cellValue) {

                continue;

            }

               

            isValid = this.onCellValidating(cellValue, columnIndex, rowId);

            if (!isValid) {

                return false;

            }

        }

        return isValid;

    }

 

This code is working; however I am having trouble when trying to unit test this. In my unit test when getting one of the rows and inspecting the cell values for that row (‘getCellValue’) as per the function above, these are empty. A bit more explanation here on how I set up the unit tests:

-          I push the data into the grid dataSource

-          I create the column definitions and assign in the gridOptions

 

I have tried doing things like this in my unit test to force the cells to have some values, without luck

 

jQuery('#' + sut.id).igGridUpdating('updateRow', rows[0].blah, { 'col0': 10, col1: 0.02, col2: 0.03 });

jQuery('#' + sut.id).igGrid('getCellValue', rows[0].blah, 'col0');

 

  1. Why are the cells values empty in the grid?
  2. How can I push values into the cells (or row) from my unit test?

 

Thanks

Mercedes

Parents
No Data
Reply
  • 23953
    Offline posted

    Hello Mercedes,

    I'm not sure what's going on here. Do you have a sample that I can investigate?

    Thanks in advance,
    Martin Pavlov
    Infragistics, Inc.

Children
No Data