60
Views
11
Comments
Solved
[OutSystems Data Grid] DataGrid is showing 0 instead of Blank in Dropdown
outsystems-data-grid
Reactive icon
Forge asset by OutSystems

The code is no longer working when I updated a DataGrid. Please help!!!


This is my JS code:

GridAPI.GridManager.GetGridById($parameters.GridWidgetId).provider.updatingLayout.addHandler(function(grid) {  

 grid.rows.forEach(function(row) {       

if (row.dataItem && row.dataItem.AccountClient && row.dataItem.AccountClient.ClientTypeID === 0) {           row.dataItem.Sample_Product.Category = undefined;      

 } 

  });

});

2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hi @Edward Muratov 

I was able to achieve that by adding the following script to the Grid Initialize event handler:

const flexGrid  = OutSystems.GridAPI.GridManager.GetGridById($parameters.GridId).provider;

flexGrid.formatItem.addHandler((s, e) => {
    let row = s.rows[e.row],
    col = s.columns[e.col];
    
    //update cell value for Number type columns only
    if (
      e.panel.cellType  === wijmo.grid.CellType.Cell &&
      (
        (col.binding === 'Sample_Product.Price' && row.dataItem.Sample_Product.Price === 0)
        ||
        (col.binding === 'Sample_Product.Stock' && row.dataItem.Sample_Product.Stock === 0)
      ) &&
      !s.editRange // ignore cell content update while editing
    ) {
      e.cell.textContent = '';
    }
});

Result:


Hope it helps!

Cheers,
GM

2025-12-04 09-01-03
Kiet Phan
Champion

Hi @Edward Muratov,

it's hard to help you without testing with code. Can you share your OML, we will check on it.

UserImage.jpg
Edward Muratov

Attached please find a copy of the oml. Thanks

Test.oml
2025-12-04 09-01-03
Kiet Phan
Champion

I'm working on js, but it's pretty hard now, not yet have solution, 

but the solution that add the blank text and for 0 value into dropdown option still works, should you use this solution.


2024-09-17 12-24-07
Rammurthy Naidu Boddu
Champion

HI @Edward Muratov

The below link help you to resolve your issue. Already in the forum the solution available

https://www.outsystems.com/forums/discussion/71342/outsystems-data-grid-dropdownlisttype-is-display-0-when-having-0-or-nullidentif/

UserImage.jpg
Edward Muratov

This is an old solution, Anyway, it didn't work. 

2022-11-12 11-28-30
Gonçalo Martins
Staff

Hello @Edward Muratov 

To make collaboration more efficient, please share a sample oml with your case so we can reproduce it without any missing references since the one you shared simply doesn't work with so many missing references.

Also, you seem to be using version 2.11.0, could you indicate which version were you using where you have that code being used? 

Cheers,
GM

2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hi @Edward Muratov 

I was able to achieve that by adding the following script to the Grid Initialize event handler:

const flexGrid  = OutSystems.GridAPI.GridManager.GetGridById($parameters.GridId).provider;

flexGrid.formatItem.addHandler((s, e) => {
    let row = s.rows[e.row],
    col = s.columns[e.col];
    
    //update cell value for Number type columns only
    if (
      e.panel.cellType  === wijmo.grid.CellType.Cell &&
      (
        (col.binding === 'Sample_Product.Price' && row.dataItem.Sample_Product.Price === 0)
        ||
        (col.binding === 'Sample_Product.Stock' && row.dataItem.Sample_Product.Stock === 0)
      ) &&
      !s.editRange // ignore cell content update while editing
    ) {
      e.cell.textContent = '';
    }
});

Result:


Hope it helps!

Cheers,
GM

UserImage.jpg
Edward Muratov

Hi Gonçalo Martins! Unfortunately, this code doesn't work for me. Thanks

2022-11-12 11-28-30
Gonçalo Martins
Staff

Hi @Edward Muratov 

Could you at least expand a bit more on "this code doesn't work for me" and share an example of your implementation?

Cheers,
GM

UserImage.jpg
Edward Muratov
Test.oml
2022-11-12 11-28-30
Gonçalo Martins
Staff

@Edward Muratov that OML has more than 100 errors due to missing dependencies so please isolate your Grid page. 

Also, you didn't mention which type of columns you mean so the example is for Number columns since the Dropdowns already have that behavior by default unless you have some bad data.

Here's a sample OML with this working, so check it working with both Number Columns affected by the code I gave and dropdowns with the default behavior: 

Please check if your bindings are correct, as I can't replicate anything without having your app in runtime.

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