Hi All, I have a requirment in my Interface that I am displaying the data in a grid through Expression rule . But in that there are some fields like say isA , isB and isC with 0 and 1 value in database . But now the The condition is that I have to show the Yes , No , N/A instead of 0 and 1 on some conditions like
1. If isA is 0 in database then isB and isC should be N/A in the grid and isA will No in the grid
2. If isA is 1 and isB is 0 in the database then isA will be yes , isB will No and isC is N/A in the Grid
3. If isA is 1 and isB is 1 in the database then isA will be yes , isB will be Yes and isC yes/No based on value in database
Thanks in advance
Discussion posts and replies are publicly visible
Hi Saurabh,
Hope below code snippet would help you..
a!localVariables( local!data: { a!map(isA: 0, isB: 0, isC: 1), a!map(isA: 0, isB: 0, isC: 1), a!map(isA: 0, isB: null, isC: 1), a!map(isA: 1, isB: null, isC: null) }, { a!gridField( label: "Read-only Grid", labelPosition: "ABOVE", data: local!data, columns: { a!gridColumn( label: "isA", value: fn!displayvalue(fv!row.isA, { 0, 1 }, { "No", "Yes" }, "N/A") ), a!gridColumn( label: "isB", value: fn!displayvalue(fv!row.isB, { 0, 1 }, { "No", "Yes" }, "N/A") ), a!gridColumn( label: "isC", value: fn!displayvalue(fv!row.isC, { 0, 1 }, { "No", "Yes" }, "N/A") ) }, validations: {} ) })
But here in local!data variable i am using to Expression rule to get all data. So is I have to takes another variable then i can use that in the grid . Is it Possible
The example here uses a locally declared variable to simulate your data structure, it doesn't end up mattering very much whether your actual source for the data is an expression rule (that's perfectly fine). The point is the operations in the value parameters of each a!gridColumn(). Though i'm not sure the above example actually satisfies the conditions you laid out in the original post so...
The easiest thing to use in this case is probably a good old-fashioned "Nested If" for the values of the isB and isC columns (even though I usually try to avoid those in most other circumstances).
Borrowing Nitesh's original code, here's my suggested version:
a!localVariables( local!data: { a!map(isA: 0, isB: 0, isC: 1), a!map(isA: 0, isB: 0, isC: 1), a!map(isA: 0, isB: null, isC: 1), a!map(isA: 1, isB: null, isC: null), a!map(isA: 1, isB: 1, isC: 1) }, { a!gridField( label: "Read-only Grid", labelPosition: "ABOVE", data: local!data, columns: { a!gridColumn( label: "isA", value: if(fv!row.isA, "Yes", "No") ), a!gridColumn( label: "isB", value: if(fv!row.isA, if(fv!row.isB, "Yes", "No"), "N/A") ), a!gridColumn( label: "isC", value: if(fv!row.isA, if(fv!row.isB, if(fv!row.isC, "Yes", "No"), "N/A"), "N/A") ) }, validations: {} ) } )