load( local!employeeData: { {id: "john.smith", first: "John", last: "Smith", email: "john.smith@example.com"}, {id: "michael.johnson", first: "Michael", last: "Johnson", email: "michael.johnson@example.com"}, {id: "elizabeth.ward", first: "Elizabeth", last: "Ward", email: "elizabeth.ward@example.com"} }, local!gridSelection: a!gridSelection( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 25, sort: a!sortInfo( field: "last", ascending: true ) ) ), local!newgridSelection: a!gridSelection( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 25, sort: a!sortInfo( field: "last", ascending: true ) ) ), local!selectedEmployeeId, local!itemsToken, local!selectedEmpIndices, local!selectedEmplList, with( /* Replace the value of local!datasubset with your query rule, or queryrecord(), * or use your own CDT array in todatasubset() */ local!datasubset: todatasubset(local!employeeData, local!gridSelection.pagingInfo), /*local!selectedEmpIndices: if ( or(isnull(local!selectedEmployeeId), length(local!selectedEmployeeId)=0), {}, apply(lookup(local!employeeData.id, _), local!selectedEmployeeId)), local!selectedEmplList: index(local!employeeData, local!selectedEmpIndices, {}), local!newdatasubset: todatasubset(local!selectedEmplList, local!newgridSelection.pagingInfo),*/ a!formLayout( label: "SAIL Example: Limit Grid Selection to One Row", firstColumnContents:{ a!gridField( label: "Employees", totalCount: local!datasubset.totalCount, columns: { a!gridTextColumn(label: "First", field: "first", data: index(local!datasubset.data, "first", {})), a!gridTextColumn(label: "Last", field: "last", data: index(local!datasubset.data, "last", {})), a!gridTextColumn(label: "Email", field: "email", data: index(local!datasubset.data, "email", {})) }, identifiers: index(local!datasubset.data, "id", {}), value: local!gridSelection, saveInto: { local!gridSelection, local!selectedEmployeeId << index(_, "selected", null), a!save(local!selectedEmpIndices, if( or(isnull(local!selectedEmployeeId), length(local!selectedEmployeeId)=0), {}, apply(lookup(local!employeeData.id, _), local!selectedEmployeeId))), a!save(local!selectedEmplList,index(local!employeeData, local!selectedEmpIndices, {})) }, selection: true ), if ( or(isnull(local!selectedEmployeeId),count(local!selectedEmployeeId) = 0), {}, a!gridLayout( /*totalCount: local!newdatasubset.totalCount,*/ headerCells: { a!gridLayoutHeaderCell(label: "First name"), a!gridLayoutHeaderCell(label: "Last name"), a!gridLayoutHeaderCell(label: " E-mail"), a!gridLayoutHeaderCell(label: "") }, columnConfigs: { a!gridLayoutColumnConfig( width: "DISTRIBUTE" ), a!gridLayoutColumnConfig( width: "DISTRIBUTE" ), a!gridLayoutColumnConfig( width: "DISTRIBUTE" ), a!gridLayoutColumnConfig( width: "NARROW" ) }, rows: a!applyComponents( function: rule!rule_rows( items: local!selectedEmplList,/*local!newdatasubset.data,*/ index: _, itemsToken: local!itemsToken ), array: if( or( isnull( local!selectedEmplList/*local!newdatasubset.data*/ ), count( local!selectedEmplList/*local!newdatasubset.data*/ ) < 1 ), {}, 1 + enumerate( count( local!selectedEmplList/*local!newdatasubset.data*/ ) ) ), arrayVariable: local!itemsToken ) ) ) }, buttons: a!buttonLayout( primaryButtons: a!buttonWidgetSubmit(label: "Submit") ) ) ) )