Hi guys,
I have a Editable grid with 4 columns
Name, Gender, Phone Number, Approve
Where approve is a checkbox field and remaining all are text field
And user Enters multiple values into the grid
Now I need to show the data which user entered in Editable grid
into another Grid(Read only) where Approve box is checked only from Editable grid
I am able to retrieve the data into Read only grid but I am not able to filter where Approve checkbox is marked
This is all in the same Interface
Thank you
Discussion posts and replies are publicly visible
Hi viswanath.ch, please check out the following code
load( local!data: { { Name: "AA", Gender: "M", PhoneNumber: "123", Approve: false() }, { Name: "BB", Gender: "F", PhoneNumber: "456", Approve: true() }, { Name: "CC", Gender: "M", PhoneNumber: "789", Approve: false() }, { Name: "DD", Gender: "F", PhoneNumber: "741", Approve: true() } }, { with( local!filteredData: index( local!data, wherecontains( true(), toboolean( local!data.Approve ) ), {} ), { a!gridLayout( label: "Editable Grid", labelPosition: "ABOVE", headerCells: { a!gridLayoutHeaderCell( label: "Name" ), a!gridLayoutHeaderCell( label: "Gender" ), a!gridLayoutHeaderCell( label: "Phone Number" ), a!gridLayoutHeaderCell( label: "Approve" ) }, columnConfigs: { a!gridLayoutColumnConfig( width: "NARROW" ), a!gridLayoutColumnConfig( width: "NARROW" ), a!gridLayoutColumnConfig( width: "NARROW" ), a!gridLayoutColumnConfig( width: "ICON" ) }, rows: a!forEach( items: local!data, expression: a!gridRowLayout( contents: { a!textField( value: fv!item.Name, saveInto: fv!item.Name ), a!textField( value: fv!item.Gender, saveInto: fv!item.Gender ), a!textField( value: fv!item.PhoneNumber, saveInto: fv!item.PhoneNumber ), a!checkboxField( choiceLabels: { null }, choiceValues: true(), value: if( toboolean( fv!item.Approve ) <> true, null, true() ), saveInto: fv!item.Approve ) } ) ), selectionSaveInto: {}, validations: {}, shadeAlternateRows: true ), a!gridField( label: "Read-only Grid (Selected Rows)", labelPosition: "ABOVE", data: local!filteredData, columns: { a!gridColumn( label: "Name", sortField: "Name", value: fv!row.Name ), a!gridColumn( label: "Gender", sortField: "Gender", value: fv!row.Gender ), a!gridColumn( label: "PhoneNumber", sortField: "PhoneNumber", value: fv!row.PhoneNumber ), }, validations: {} ) } ) })
Thank you very much. Its working now
But i have problem now
If the user did not enter any values in Editable grid, then Read-only Grid(Selected Rows) showing an error
""Expression evaluation error at function 'wherecontains' parameter 2 [line 407]: Invalid index: Cannot index property 'approve' of type Text into null value of type data?list""
data is ri!data
and i used
a!checkboxField( label: "Approved" & fv!index, labelPosition: "ABOVE", choiceLabels: { " " }, choiceValues: { "Yes" }, value: fv!item.approve, saveInto: fv!item.approve, required: true, validations: {}, align: "CENTER" )
instead of
a!checkboxField(choiceLabels: {null},choiceValues: true(),value: if(toboolean(fv!item.Approve) <> true,null,true()),saveInto: fv!item.Approve)})
check out the new validations and also the add row link
load( local!data: {}, { with( local!filteredData: index( local!data, wherecontains( true(), toboolean( index( local!data, "Approve", {} ) ) ), {} ), { a!gridLayout( label: "Editable Grid", labelPosition: "ABOVE", headerCells: { a!gridLayoutHeaderCell( label: "Name" ), a!gridLayoutHeaderCell( label: "Gender" ), a!gridLayoutHeaderCell( label: "Phone Number" ), a!gridLayoutHeaderCell( label: "Approve" ) }, columnConfigs: { a!gridLayoutColumnConfig( width: "NARROW" ), a!gridLayoutColumnConfig( width: "NARROW" ), a!gridLayoutColumnConfig( width: "NARROW" ), a!gridLayoutColumnConfig( width: "ICON" ) }, rows: a!forEach( items: local!data, expression: a!gridRowLayout( contents: { a!textField( value: fv!item.Name, saveInto: fv!item.Name ), a!textField( value: fv!item.Gender, saveInto: fv!item.Gender ), a!textField( value: fv!item.PhoneNumber, saveInto: fv!item.PhoneNumber ), a!checkboxField( choiceLabels: { null }, choiceValues: true(), value: if( toboolean( fv!item.Approve ) <> true, null, true() ), saveInto: fv!item.Approve ) } ) ), selectionSaveInto: {}, validations: {}, shadeAlternateRows: true, addRowLink: a!dynamicLink( label: "Add", value: { Name: "", Gender: "", PhoneNumber: "", Approve: false() }, saveInto: a!save( local!data, append( local!data, save!value ) ) ) ), a!gridField( label: "Read-only Grid (Selected Rows)", labelPosition: "ABOVE", data: local!filteredData, columns: { a!gridColumn( label: "Name", sortField: "Name", value: fv!row.Name ), a!gridColumn( label: "Gender", sortField: "Gender", value: fv!row.Gender ), a!gridColumn( label: "PhoneNumber", sortField: "PhoneNumber", value: fv!row.PhoneNumber ), }, validations: {} ) } ) })
Thank you very much
It's working now.
mcamacho
Could you help me how to save these Read-only data(Selected Row) to a CDT
i am trying a!save in Submit button, but it's not working
As a side note... please please use this feature:
Doing so will allow preservation of formatting and (most importantly) indentation while keeping a single comment from being multiple pages long.
That is a simple save in the button
a!save(
ri!cdt /*must have the same structure as the array (names must match) */,
local!filteredData
)