Our team is working from home and we are 100% operational. Please prefer the contact form to join us.
To create a support ticket, start a search

Modifying the value entered in a grid - Grid JS onEditCell


Prerequisites

Follow instructions Products Grid: Adding a field from ps_product_lang table to create a field 'shipping info'.


Target

We would like to modify the value in field 'shipping info' to truncate the data if it goes over 100 characters, and then send this value to the server to get registered in the database.

 

Setup

From the Advanced Properties panel on the right handside:

- select the menu Grid JS onEditCell and enter:

// onEditCell(stage,rId,cInd,nValue,oValue)
// rId is the row ID
// cInd is the column INDEX
// nValue is the new value
// oValue is the old value

if (nValue != oValue) {
    idxDeliveryInfo = cat_grid.getColIndexById('infos_livraison');
    if (cInd == idxDeliveryInfo) {
        cat_grid.cells(rId, idxDeliveryInfo).setValue(cat_grid.cells(rId, idxDeliveryInfo).getValue().substr(0, 100));
    }
}

 

You will need to reset Store Commander to apply the new modifications.