Spreadjs : getDirtyRows and validation issues

Posted by: rahulsc on 8 September 2017, 9:47 am EST

  • Posted 8 September 2017, 9:47 am EST

    Hi,

    I am using spreadjs for one of our company projects. Is there any way for me to set up a data state which getDirtyRows compares against to get the modifed rows? The issue is that I am using an API to get the JSON formatted data and binding it to the sheet. Then I am adding an additional 500 rows. getDirtyRows always returns ALL the rows that are in the sheet including the empty ones. Also this same sheet is a generic sheet that is used for some 80 odd classifications of data. At times the getDirtyRows function returns the exact same rows in both Item and originalItem.

    Is there a way for me to tell spreadjs which initial data to compare against? Specifically I want to bind the data, add the extra rows and then set this as the originalState of the sheet.

    On the validation front I was wondering if there is any function which can tell me if any validation on the sheet is failing. From what I see in the API I have to call all validators one by one and check their state.

    Thanks and Regards,

    Rahul

  • Posted 8 September 2017, 9:47 am EST

    Hi Rahul,

    Now getDirtyRows has some problems, it isn’t full functional. We have plan to provide a set of full functional APIs in coming release.

    Hope it helps,

  • Posted 8 September 2017, 9:47 am EST

    Hi Eric,

    Thanks for the update. I used the clearPendingChanges API to achieve the behavior I wanted. They seem to be working ok for now. There’s one bug however. I have combobox cell types in my spreadsheet and the hasPendingChanges API doesn’t register that the user has chosen a new value in the drop down. It however works fine if the new value is typed into the box. Is there a way to fix this which I can use while I wait for the next release? And do you have a timeline for when that will be?

     Also can you address the second issue? I need to check the validation for a sheet before I save the data. Is there a way to check this validation on the sheet level? Right now I am having to retrieve the datavalidator for every cell and see if it has failed.
    

    Thanks for the help.

  • Posted 8 September 2017, 9:47 am EST

    As plan, next release will be middle of Nov.

    As for sheet level validation result, we only have ability to show all errors with a red circle by using highlightInvalidData method. There is no API to get all invalid value cells, this maybe a point we add in future.

  • Posted 8 September 2017, 9:47 am EST

    Thanks for the update Eric on the schedule.

    For the validation part, I do not need the invalid value cells. I just need to know if there are any and break the save operation if there are. The value doesn’t matter as long as I can determine that there are pending validations to be satisfied before allowing a save. A sheet level API which provides this information would be amazingly helpful.

  • Posted 8 September 2017, 9:47 am EST

    For now, we don’t have such API on sheet, maybe consider in future.

    Now can only loop each cell to get validation status:

    [js]

    $(“#ss”).wijspread();

    var spread = $(“#ss”).wijspread(“spread”);

    var sheet = spread.getActiveSheet();

    var row = sheet.getRowCount();

    var col = sheet.getColumnCount();

    var result = ;

    for (var i = 0; i < row; i++) {

    for (var j = 0; j < col; j++) {

    var cellValue = sheet.getValue(i, j);

    if (!sheet.isValid(i, j, cellValue)) {

    result.push({ row: i, col: j, value: cellValue });

    }

    }

    }

    [/js]

  • Posted 8 September 2017, 9:47 am EST

    Thank you for the code update. I am using that in combination with the getDirtyRows API and it seems to be working fine.

    I had one last question regarding dirtyRows. Since our release is scheduled for this month end and new spreadjs release will be after that can you offer a quickfix for the drop down change not registering as dirty row issue? I see from the code that the row needs to be marked as dirty using a flag but if there’s a way to do that without me modifying anything in the spreadjs script it would be extremely helpful. Is there anyway I can set the row as dirty based on a drop down changed event?

  • Posted 20 December 2017, 1:36 pm EST

    Hi Eric,

    What is the status of getDirtyRows fix? Is it released? As I don’t see it on page -

    https://www.grapecity.com/en/controls/spreadjs/whats-new

    Thanks

  • Posted 22 December 2017, 10:04 am EST

    Hello,

    getDirtyRows currently check the dirty rows collection and it has three return values. Please check more about is here:

    http://help.grapecity.com/spread/SpreadSheets11/webframe.html#SpreadJS~GC.Spread.Sheets.Worksheet~getDirtyRows.html

    There is one sample application I created, this check for the cells with invalid data using isvalid method. Please have a look at it.

    Thanks,

    Deepak Sharma

    DataValidationgetCells.zip

  • Posted 27 December 2017, 6:38 pm EST

    Hi,

    Thanks for prompt reply, but you didn’t answer my question. Was the fix released as told by Eric?

    Thanks

  • Posted 28 December 2017, 10:00 am EST

    Hi Saurabh,

    I found one ticket where a similar issue was discussed and this was the the final outcome of the issue discussed:

    GetDirtyRows() method is for the data bound use case, it is meanless for un-bound mode. Usually, it is used for CRUD operations.

    But getDirtyCells() is works for both bound mode and unbound mode, and more suitable for un-bound mode.

    In your case(first post by rahulsc )you are loading the data through fromJSON which makes it an unbound sheet hence, getDirtyRows() don’t take effect.

    Thanks,

    Deepak Sharma

  • Posted 3 December 2018, 3:35 am EST

    Hi Deepak,

    We are also loading data through fromJSON API.

    what is the solution to get deleted rows.

    Thanks

    Manoj

Need extra support?

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

Learn More

Forum Channels