304
Views
11
Comments
Solved
[OutSystems Data Grid Web] Using setCellValue results in an error
outsystems-data-grid-web
Web icon
Forge asset by OutSystems

hi,

What worked correctly at Version 2.1.6 stopped working at Version 2.1.7.

I want to rewrite Grid's Cell from ScreenAction.
At the time of Version2.1.6, update was performed using "setCellValue".

This version 2.1.7 has stopped working properly.
When undoStackActive = True, it becomes False at gObj.undoStack._openAction! == undefined of "setCellValue",
An error occurs because this cannot be acquired in GridEditAction.

Do I need to do anything before using setCellValue?

2020-10-19 05-14-26
Huyen IT
Solution

Yuichiro Tada wrote:

hi, Huyen IT,


Certainly, if you only want to rewrite the value of Cell, I think that there is no problem with "setCellValue".

I want to set the Dirty so that I know that the value has changed.

In actual implementation, Notify of Popup is set from Action.


hi, Pedro Romãozinho,

I understand that there is not enough instance quota.

Before the response, the process was proceeding on the premise that an instance was created, but is there any effect on other things?


Yuichiro san,

Maybe requirement of each screen is different. I always process "Cell-Dirty" manually.


>>The target Cell may be editable, so I want it to work properly.

>>Do you have any good ideas?

Can you explain in more detail?


2020-10-19 05-14-26
Huyen IT

Yuichiro san,

Why you need using "setCellValue" function? can you take a screenshot error?

I tried debug but it was not called.

Usually I use "setCellData" only.

Regards.

UserImage.jpg
Yuichiro Tada

Huyen IT wrote:

Yuichiro san,

Why you need using "setCellValue" function? can you take a screenshot error?

I tried debug but it was not called.

Usually I use "setCellData" only.

Regards.


thank you for your reply.

I used GridOS.ExternalAPI.setCellValue in GridFramework's External API's and used it.
External calls seemed to be appropriate.
In this process, setCellData is also called, but there are several processes that seem important before and after.

Is it OK to just call setCellData?

2020-10-19 05-14-26
Huyen IT

Yuichiro Tada wrote:

Huyen IT wrote:

Yuichiro san,

Why you need using "setCellValue" function? can you take a screenshot error?

I tried debug but it was not called.

Usually I use "setCellData" only.

Regards.


thank you for your reply.

I used GridOS.ExternalAPI.setCellValue in GridFramework's External API's and used it.
External calls seemed to be appropriate.
In this process, setCellData is also called, but there are several processes that seem important before and after.

Is it OK to just call setCellData?

Yuichiro san,

>>In this process, setCellData is also called, but there are several processes that seem important before and after.

I can see "setCellValue" function is like end user input:

    1. Mark dirty cell with old and new value. 

    2. Create undo/redo for this cell.            (I think this part for End user, when manual input)

    3. Set value of the cell. 

    4. Validate the cell. 

And I need to differentiate between user input and automatic calculation or dynamic cell, so I don't use "setCellValue" function.

I think It OK if you can control the cell.

Regards.

2018-04-05 08-23-47
Pedro Romãozinho
Staff

Hi Yuichiro,

The problem is a missing new word to assign an instance of GridEditAction.

You can redefine the setCellValue function on your side in the meanwhile, before it get fixed, by including this script in the JavaScript of your WebBlock/Screen:

GridOS.ExternalAPI.setCellValue = function(row, col, value, gridId) {
    var gObj = GridOS.ComponentUtils.getGridObjectById(gridId);

    var _flexGrid = gObj.grid;
    var _panel = _flexGrid;
    var _dataItem = _flexGrid.rows[row].dataItem;

    var _binding;
    var _col;
    if (typeof(col) === 'number') {
        _binding = _flexGrid.columns[col].binding;
        _col = col;
    }
    else {
        _binding = col;
        _col = _flexGrid.columns.getColumn(_binding).index;
    }

    var _cellEvent = {
        panel: _panel,
        row: row,
        col: _col,
        os_dataItem: _dataItem,
        os_binding: _binding
    };
    var undoStackActive = gObj.outsystemsOptions.undoStackActive;
    if (undoStackActive) {
        if (gObj.undoStack._openAction !== undefined) { // Check if is old undoStack
            gObj.undoStack._openAction(new GridEditAction(_flexGrid, _cellEvent)); // From UndoStack: add to the stack the current state, before changing the value
        }
        else { // If is the new undoStack
            gObj.undoStack._pendingAction = new GridEditAction(_flexGrid, _cellEvent); // From UndoStack: add to the stack the current state, before changing the value
        }
    }
    // Before set the value of the cell get the current value, the old value
    GridOS.EditEngine.onBeforeEditing(gObj.gridId, _flexGrid, _cellEvent);

    // Set value of the cell
    _flexGrid.cells.setCellData(row, _col, value);

    // Mark as dirty if the new value set is different than the old
    GridOS.EditEngine.setDirtyCell(gObj.gridId, _flexGrid, _cellEvent);
    // Validate the cell
    GridOS.EditEngine.validateErrors(_flexGrid, _cellEvent, gObj);

    if (undoStackActive) {
        if (gObj.undoStack._openAction !== undefined) { // Check if is old undoStack
            gObj.undoStack._closePendingAction(); // From UndoStack: add to the stack the state after changing the value
        }
        else { // If is the new undoStack
            if (gObj.undoStack._pendingAction instanceof GridEditAction) {
                gObj.undoStack.pushPendingAction();
            } // From UndoStack: add to the stack the state after changing the value
        }
    }
};

UserImage.jpg
Yuichiro Tada

hi, Huyen IT,


Certainly, if you only want to rewrite the value of Cell, I think that there is no problem with "setCellValue".

I want to set the Dirty so that I know that the value has changed.

In actual implementation, Notify of Popup is set from Action.


hi, Pedro Romãozinho,

I understand that there is not enough instance quota.

Before the response, the process was proceeding on the premise that an instance was created, but is there any effect on other things?


2020-10-19 05-14-26
Huyen IT
Solution

Yuichiro Tada wrote:

hi, Huyen IT,


Certainly, if you only want to rewrite the value of Cell, I think that there is no problem with "setCellValue".

I want to set the Dirty so that I know that the value has changed.

In actual implementation, Notify of Popup is set from Action.


hi, Pedro Romãozinho,

I understand that there is not enough instance quota.

Before the response, the process was proceeding on the premise that an instance was created, but is there any effect on other things?


Yuichiro san,

Maybe requirement of each screen is different. I always process "Cell-Dirty" manually.


>>The target Cell may be editable, so I want it to work properly.

>>Do you have any good ideas?

Can you explain in more detail?


UserImage.jpg
Yuichiro Tada

Huyen IT wrote:

Yuichiro Tada wrote:

hi, Huyen IT,


Certainly, if you only want to rewrite the value of Cell, I think that there is no problem with "setCellValue".

I want to set the Dirty so that I know that the value has changed.

In actual implementation, Notify of Popup is set from Action.


hi, Pedro Romãozinho,

I understand that there is not enough instance quota.

Before the response, the process was proceeding on the premise that an instance was created, but is there any effect on other things?


Yuichiro san,

Maybe requirement of each screen is different. I always process "Cell-Dirty" manually.


>>The target Cell may be editable, so I want it to work properly.

>>Do you have any good ideas?

Can you explain in more detail?


I am currently experimenting with using "setCellData".
It is not working well.
Sorry, can I get a sample OML?


2020-10-19 05-14-26
Huyen IT

Yuichiro Tada wrote:

Huyen IT wrote:

Yuichiro Tada wrote:

hi, Huyen IT,


Certainly, if you only want to rewrite the value of Cell, I think that there is no problem with "setCellValue".

I want to set the Dirty so that I know that the value has changed.

In actual implementation, Notify of Popup is set from Action.


hi, Pedro Romãozinho,

I understand that there is not enough instance quota.

Before the response, the process was proceeding on the premise that an instance was created, but is there any effect on other things?


Yuichiro san,

Maybe requirement of each screen is different. I always process "Cell-Dirty" manually.


>>The target Cell may be editable, so I want it to work properly.

>>Do you have any good ideas?

Can you explain in more detail?


I am currently experimenting with using "setCellData".
It is not working well.
Sorry, can I get a sample OML?


Sorry, I don't have any sample for this.

But "Cell-Dirty" is very important to process "user input data", and i need distinct with "auto fill data".

Moreover "setCellValue" has a lot of processing and I feel PG will be slow if using it.

Regards.

UserImage.jpg
Yuichiro Tada

Huyen IT wrote:

Yuichiro Tada wrote:

Huyen IT wrote:

Yuichiro Tada wrote:

hi, Huyen IT,


Certainly, if you only want to rewrite the value of Cell, I think that there is no problem with "setCellValue".

I want to set the Dirty so that I know that the value has changed.

In actual implementation, Notify of Popup is set from Action.


hi, Pedro Romãozinho,

I understand that there is not enough instance quota.

Before the response, the process was proceeding on the premise that an instance was created, but is there any effect on other things?


Yuichiro san,

Maybe requirement of each screen is different. I always process "Cell-Dirty" manually.


>>The target Cell may be editable, so I want it to work properly.

>>Do you have any good ideas?

Can you explain in more detail?


I am currently experimenting with using "setCellData".
It is not working well.
Sorry, can I get a sample OML?


Sorry, I don't have any sample for this.

But "Cell-Dirty" is very important to process "user input data", and i need distinct with "auto fill data".

Moreover "setCellValue" has a lot of processing and I feel PG will be slow if using it.

Regards.

Huyen IT san,

By using setCellData, the value was successfully updated.
In addition, the target data could be updated normally by fetching rows using os_RowId.

Thank you very much.


UserImage.jpg
Yuichiro Tada

I tried to create an instance, but Undo does not work.

The target Cell may be editable, so I want it to work properly.

Do you have any good ideas?


By the way, it works normally when SendDefaultValues of REST API is set to Yes.

Is this fix correct?

2018-04-05 08-23-47
Pedro Romãozinho
Staff

Try this sample which implements the setCellValue

Sample.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.