Skip to main content
March 16, 2022
Question

Selectable grid

  • March 16, 2022
  • 11 replies
  • 0 views

Hi, I am trying build read only selectable grid.

a!localVariables(
local!businessModuleStatus: rule!CR_QE_getModuleStatusForBusiness(
cif_int: ri!cif_int,
moduleId_int: ri!moduleId_int
),
a!boxLayout(
label: index(
local!businessModuleStatus,
"workflowDesc_txt",
""
),
style: "ACCENT",
contents: {
a!gridLayout(
spacing: "DENSE",
headerCells: {
a!forEach(
items: cons!CR_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS,
expression: a!gridLayoutHeaderCell(
label: fv!item,
align: "LEFT"
)
)
},
columnConfigs: {
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 2
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 2
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 2
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 2
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 2
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: 2
)
},
rows: {
a!forEach(
items: local!businessModuleStatus,
expression: a!gridRowLayout(
id: fv!item.inputRequestId1_int,
contents: {
a!textField(
value: fv!item.workflowDesc_txt,
readOnly: true(),
align: "LEFT"
),
a!textField(
value: rule!APN_FN_getDisplayName(
userId: fv!item.initiatedBy_txt
),
readOnly: true(),
align: "LEFT"
),
a!textField(
value: rule!CR_FN_DateTimeFormat(
input: fv!item.initiatedOn_dt
),
readOnly: true(),
align: "LEFT"
),
a!textField(
value: fv!item.moduleStatus_txt,
readOnly: true(),
align: "LEFT"
),
a!textField(
value: rule!APN_FN_getDisplayName(
userId: fv!item.approvedBy_txt
),
readOnly: true(),
align: "LEFT"
),
a!textField(
value: rule!CR_FN_DateTimeFormat(
input: fv!item.approvedOn_dt
),
readOnly: true(),
align: "LEFT"
)
}
)
)
},
selectable: true(),
selectionStyle: "ROW_HIGHLIGHT",
selectionValue: ri!inputSelectedId_int,
selectionSaveInto: {
a!save(
ri!inputSelectedId_int,
tointeger(
index(
reverse(
save!value
),
1,
null
)
)
),
a!save(
ri!systemSelectedId_int,
index(
local!businessModuleStatus,
"systemRequestId_int",
""
),

)
},
selectionRequired: true()
)
}
)
)

On selection of row one variable will get updated due to Id of a row, then if i retrieve value for second variable from localvariable. It is not updating for second variable if I select a new row.

Can someone suggest on this?

    11 replies

    viraty527193
    March 16, 2022

    Hi it seems you have a problem while saving the value in  ri!systemSelectedId_int, I'm assuming you want to save the systemRequestId_int of the selected row, what is happening in the code above is all the systemRequestId_int  are getting saved in the ri due to the below code

    a!save(
    ri!systemSelectedId_int,
    index(
    local!businessModuleStatus,
    "systemRequestId_int",
    ""
    )

    But I suppose the ri can only hold single value hence it will get the very first value every time in order to save the selected row value use this 

    a!save(
    ri!systemSelectedId_int,
    index(
    local!businessModuleStatus,
    "systemRequestId_int",
    ""
    )[selectedIndex]

    If you are showing a read-only grid that requires selection there is a very useful SAIL recipe for the same  read only grid with selection 

    I hope this helps [emoticon:c4563cd7d5574777a71c318021cbbcc8]

    March 16, 2022

    what is here [selectedIndex]? Could you please tell?

    viraty527193
    March 16, 2022

    as you select the value the index is what gets selected you must have been saving it in ri or local, please pass that 

    gopalk2865
    Participating Frequently
    March 16, 2022

    Hi, After selection , you dont need to index to choose selected row, you can just  use fv!selectedRows for selection  and fv!deselectedRows for deselection. You can go through the link provided by viraty as well.

    March 16, 2022

    a!localVariables(
    local!businessModuleStatus: rule!CR_QE_getModuleStatusForBusiness(
    cif_int: ri!cif_int,
    moduleId_int: ri!moduleId_int
    ),
    local!selectedId_int,
    local!selectedValues,
    a!boxLayout(
    label: index(
    local!businessModuleStatus,
    "workflowDesc_txt",
    ""
    ),
    style: "ACCENT",
    contents: a!gridField(
    data: local!businessModuleStatus,
    columns: {
    a!gridColumn(
    label: cons!MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[1],
    sortField: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[1],
    value: fv!row.workflowDesc_txt
    ),
    a!gridColumn(
    label: cons!MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[2],
    sortField: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[2],
    value: rule!APN_FN_getDisplayName(
    userId: fv!row.initiatedBy_txt
    ),

    ),
    a!gridColumn(
    label: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[3],
    sortField: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[3],
    value: rule!CR_FN_nbfDateTimeFormat(
    input: fv!row.initiatedOn_dt
    ),

    ),
    a!gridColumn(
    label: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[4],
    sortField: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[4],
    value: fv!row.moduleStatus_txt
    ),
    a!gridColumn(
    label: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[5],
    sortField: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[5],
    value: rule!APN_FN_getDisplayName(
    userId: fv!row.approvedBy_txt
    )
    ),
    a!gridColumn(
    label: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[6],
    sortField: cons!CR_APP_MODULE_STATUS_GRID_FIELDS_FOR_BUSINESS[6],
    value: rule!CR_FN_nbfDateTimeFormat(
    input: fv!row.approvedOn_dt
    ),

    ),

    },
    selectable: true,
    selectionStyle: "ROW_HIGHLIGHT",
    selectionValue: local!selectedId_int,
    selectionSaveInto: {
    local!selectedId_int,
    /*a!save(*/
    /*local!selectedId_int,*/
    /*tointeger(*/
    /*index(*/
    /*reverse(*/
    /*fv!selectedRows*/
    /*),*/
    /*1,*/
    /*null*/
    /*)*/
    /*)*/
    /*),*/
    a!save(
    local!selectedValues,
    append(
    local!selectedValues,
    fv!selectedRows
    )
    ),
    a!save(
    local!selectedValues,
    difference(
    local!selectedValues,
    fv!deselectedRows
    )
    ),
    a!save(
    ri!inputSelectedId_int,
    local!selectedValues.inputRequestId1_int
    ),
    a!save(
    ri!systemSelectedId_int,
    local!selectedValues.systemRequestId_int
    )
    }

    Now I am getting both values ,but it is selecting mutliple rows but my requirement is single row to be selected. Can you please help in this?

    viraty527193
    March 16, 2022

    you can restrict the row selection please refer this Limit Grid Selection to One Row