Paging Grid - Pagination on Click

=load(
  local!dataSubset : a!dataSubset(
    startIndex: 1,
    batchSize: 1,
    data: {},
    totalCount: 0
  ),
  local!expDataSubset: a!dataSubset(
    startIndex: 1,
    batchSize: 1,
    data:{},
    totalCount: 0
  ),
  local!expdPagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20
  ),
  local!pagingInfo:a!pagingInfo(
    startIndex: 1,
    batchSize: 20
  ), 
    local!rowData,
    local!selectedRows,
    local!singleLineFlag,
    local!selectedTierValue:"Tier 1",
    local!selectedReasonCode,
    local!selectedFeeReasonCode,
    local!expediteFee,
    local!carbonCopy,
  local!selectedYesNo:null,
  local!partialQuantity,
  local!initiatorComments,
  local!expediteData,
  local!apiErrorMessage,
  local!apiResult,
  local!gridSelection: a!gridSelection(
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: 20,
      sort:a!sortInfo(
        field:"line_id"
      )
    ),
    selected: {}
  ),

  a!formLayout(
  label: "Initiate Expedite",
  contents: {
    a!textField(
      label: "Order Number",
      labelPosition: "ADJACENT",
      /*instructions: "Please enter an Order Number to proceed!",*/
      value: ri!orders.order_number,
      saveInto: ri!orders.order_number,
      refreshAfter: "UNFOCUS",
      required: true,
      requiredmessage: "Value for Order Number is required"
      /*validations: a!validationMessage(*/
        /*message:"Please enter an Order Number to Proceed",*/
        /*validateAfter: "REFRESH",*/
        /*showWhen: isnull(ri!orders.order_number)*/
      /*)*/
    ),
    /*a!textField(*/
      /*label:"Check Value",*/
      /*value:local!dataSubset,*/
      /*readOnly:true()*/
    /*),*/
    a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Search",
          saveInto: {
            a!save(local!dataSubset,rule!EXP_GetExpdOrderLinesByOrdNum(ri!orders.order_number,local!pagingInfo)),
            a!save(local!expDataSubset,rule!EXP_GetExpeditedLines(local!expdPagingInfo,ri!orders.order_number))
          },
          style: "NORMAL",
          disabled: isnull(ri!orders.order_number)
        )
      },
      secondaryButtons: {}
    ),
    a!gridField(
      label: "Expedite Line Section",
        totalCount: if(local!datasubset.totalCount=0,1,local!datasubset.totalCount),
        emptyGridMessage: "Please enter a valid number order number to search for eligible lines ",
        columns: {
        a!gridTextColumn(
          label:"Line Number",
          field:"line_number",
          data:index(local!dataSubset.data,"line_number","")
        ),
         a!gridTextColumn(
          label:"Order Number",
          field:"order_number",
          data:index(local!dataSubset.data,"order_number","")
        ),
         a!gridTextColumn(
          label:"Account Name",
          field:"account_name",
          data:index(local!dataSubset.data,"account_name","")
        ), a!gridTextColumn(
          label:"Part",
          field:"ordered_item",
          data:index(local!dataSubset.data,"ordered_item","")
        ),
         a!gridTextColumn(
          label:"Description",
          field:"description",
          data:index(local!dataSubset.data,"description","")
        ),
         a!gridTextColumn(
          label:"Quantity",
          field:"quantity",
          data:index(local!dataSubset.data,"quantity","")
        ),
         a!gridTextColumn(
          label:"RequestDate",
          field:"request_date",
          data:index(local!dataSubset.data,"request_date","")
        ),
         a!gridTextColumn(
          label:"ScheduleShipDate",
          field:"schedule_ship_date",
          data:index(local!dataSubset.data,"schedule_ship_date","")
        ),
         a!gridTextColumn(
          label:"OrganizationCode",
          field:"organization_code",
          data:index(local!dataSubset.data,"organization_code","")
        ),
         a!gridTextColumn(
          label:"SourceOrgCode",
          field:"source_org_code",
          data:index(local!dataSubset.data,"source_org_code","")
        )
      },
        identifiers:index(local!dataSubset.data, "line_id" ,  "{}"),
      value: local!gridSelection,
          saveInto: {
            local!gridSelection,
            a!save(
              local!rowData,
              index(local!dataSubset.data,
              wherecontains(
      local!gridSelection.selected,
      local!dataSubset.identifiers
    ),{})
            )
          },
       showWhen: if(local!dataSubset.totalCount >0,true(),false()),
       selection:if(local!dataSubset.totalCount >0,true,false)
    ),
    /*a!textField(*/
      /*label: "Data Set Value",*/
      /*value: local!rowData,*/
      /*readOnly: true*/
    /*),*/
 
    a!sectionLayout(
      label:"Expedite Single Line Request",
      contents: {
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!textField(
            label: "Line Number",
              value: local!rowData.line_number,
              readOnly: true
            ),
            a!textField(
              label: "Order Number",
              value: local!rowData.order_number,
              readOnly: true
            ),
            a!textField(
             label: "Customer Name",
              value: local!rowData.account_name,
              readOnly: true
            ),
            a!textField(
             label: "Part Number",
              value: local!rowData.ordered_item,
              readOnly: true
            ),
            a!textField(
             label: "Description",
              value: local!rowData.description,
              readOnly: true
            ),
             a!textField(
             label: "Quantity",
              value: local!rowData.quantity,
              readOnly: true
            ),
             /*a!dropdownField(*/
              /*label:"Tier Value",*/
              /*placeholderLabel: "--- Select Tier Value ---",*/
              /*choiceLabels: index(rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_TIERS"),"meaning",null),*/
              /*choiceValues: rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_TIERS"),*/
              /*value:local!selectedTierValue,*/
              /*saveInto: local!selectedTierValue,*/
              /*required: true()*/
            /*),*/
              a!dropdownField(
              label:"Reason Code",
              placeholderLabel: "--- Select a Reason Code ---",
              choiceLabels: index(rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_REASONS"),"meaning",null),
              choiceValues: rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_REASONS"),
              value:local!selectedReasonCode,
              saveInto: local!selectedReasonCode,
              required: true()
            ),
            a!textField(
              label: "Expedite Fee",
              value: local!expediteFee,
              saveInto: local!expediteFee
            ),
               a!dropdownField(
              label:"Fee Reason",
              placeholderLabel: "--- Select a Reason Code ---",
              choiceLabels: index(rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_FEE_REASONS"),"meaning",null),
              choiceValues: rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_FEE_REASONS"),
              value:local!selectedFeeReasonCode,
              saveInto: local!selectedFeeReasonCode
            )
          }
        ),
        a!columnLayout(
          contents: {
           
            a!textField(
              label: "Carbon Copy",
              value: local!carbonCopy,
              saveInto: local!carbonCopy
            ),
            a!textField(
              label: "Current Scheduled Date",
              value: local!rowData.schedule_ship_date,
              readOnly: true
            ),
            a!textField(
              label:"Request Date",
                value:local!rowData.request_date,
                readOnly: true()
            ),
          a!dropdownField(
             label: "Partials Accepted",
             labelPosition: "ABOVE",
             placeholderLabel: "--- Select a Value ---",
             choiceLabels: {
                   "Yes",
                   "No"
                          },
             choiceValues: {
                   "Y",
                   "N"
                          },
             value: local!selectedYesNo,
             saveInto: local!selectedYesNo
                      ),
          a!textField(
            label:"Partial Quantity",
            value:local!partialQuantity,
            saveInto: local!partialQuantity
          ),
          a!textField(
            label:"Initiator Comments",
            value:local!initiatorComments,
            saveInto: local!initiatorComments
          )
          }
        )
      }
    )
  },
  showWhen: if(or(isnull(local!rowData),or(length(local!gridSelection.selected)=0,length(local!gridSelection.selected)>1)),false,true)
    ),
     a!buttonLayout(
      primaryButtons: {
        a!buttonWidgetSubmit(
          label:"EXPEDITE",
          value:"SUBMIT",
          saveInto: {
            a!save(
              local!expediteData, a!toJson({
        "lineNumber":local!rowData.line_number,
        "orderHeaderId":local!rowData.header_id,
        "lineId":local!rowData.line_id,
        "orderType":"OE",
        "lineCount":count(local!rowData.header_id),
        "tier":index(local!selectedTierValue,"meaning",null),
        "reasonCode":index(local!selectedReasonCode,"meaning",null),
        "feeReasonCode":index(local!selectedFeeReasonCode,"meaning",null),
        "fee":local!expediteFee,
        "initiatorComments":local!initiatorComments,
        "partialQuantity":local!partialQuantity,
        "partialsAccepted":local!selectedYesNo,
        "carbonCopy":local!carbonCopy,
        "user":loggedInUser()
        
      })
            ),
            a!save(ri!orders.line_id,local!rowData.line_id),
            rule!EXP_BPM_Expereience_API(
              body: local!expediteData,
                 onSuccess: {
                   a!httpResponse_17r4(
                   statusCode: 200,
                   headers: {
                   a!httpHeader(name: "Content-Type", value: "application/json")
                            },
                  body: a!toJson_17r1(fv!result)
                   ) ,
                    a!save(ri!orders.line_id,local!rowData.line_id),
                    a!save(local!apiResult,fv!result),
                    a!save(ri!reqLineArray,index(a!fromJson(local!apiResult.body),"reqLineId",null))
                 }
            )
          },
          showWhen: if(isnull(local!rowData),false,true)
        )
       
      },
      secondaryButtons: {}
    ),
    /*a!textField(*/
     /*value: ri!reqLineArray, */
     /*readOnly: true()*/
    /*),*/
     a!sectionLayout(
      label:"Expedite Multiple Line Request",
      contents: {
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
             /*a!dropdownField(*/
              /*label:"Tier Value",*/
              /*placeholderLabel: "--- Select Tier Value ---",*/
              /*choiceLabels: index(rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_TIERS"),"meaning",null),*/
              /*choiceValues: rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_TIERS"),*/
              /*value:local!selectedTierValue,*/
              /*saveInto: local!selectedTierValue,*/
              /*required: true()*/
            /*),*/
              a!dropdownField(
              label:"Reason Code",
              placeholderLabel: "--- Select a Reason Code ---",
              choiceLabels: index(rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_REASONS"),"meaning",null),
              choiceValues: rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_REASONS"),
              value:local!selectedReasonCode,
              saveInto: local!selectedReasonCode,
              required: true()
            ),
            a!textField(
              label: "Expedite Fee",
              value: local!expediteFee,
              saveInto: local!expediteFee
            ),
               a!dropdownField(
              label:"Fee Reason",
              placeholderLabel: "--- Select a Reason Code ---",
              choiceLabels: index(rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_FEE_REASONS"),"meaning",null),
              choiceValues: rule!EXP_GetEBSLookupValuesbyCode("PANDUIT_EXPEDITE_FEE_REASONS"),
              value:local!selectedFeeReasonCode,
              saveInto: local!selectedFeeReasonCode
            ),
                     
            a!textField(
              label: "Carbon Copy",
              value: local!carbonCopy,
              saveInto: local!carbonCopy
            ),
          a!dropdownField(
             label: "Partials Accepted",
             labelPosition: "ABOVE",
             placeholderLabel: "--- Select a Value ---",
             choiceLabels: {
                   "Yes",
                   "No"
                          },
             choiceValues: {
                   "Y",
                   "N"
                          },
             value: local!selectedYesNo,
             saveInto: local!selectedYesNo
                      ),
          a!textField(
            label:"Partial Quantity",
            value:local!partialQuantity,
            saveInto: local!partialQuantity
          ),
          a!textField(
            label:"Initiator Comments",
            value:local!initiatorComments,
            saveInto: local!initiatorComments
          )
          }
        )
      }
    )
  },
  showWhen: if(or(isnull(local!rowData),or(length(local!gridSelection.selected)=0,length(local!gridSelection.selected)=1)),false,true)
    ),
    a!gridField(
      label: "Expedited Order Lines Info",
      instructions: "To Re-Submit or Cancel the expedited lines, please go to Records Tab and use Related Actions.",
      columns: {
          a!gridTextColumn(
          label:"Line Number",
          field:"line_number",
          data:index(local!expDataSubset.data,"line_number","")
        ),
         a!gridTextColumn(
          label:"Order Number",
          field:"order_number",
          data:index(local!expDataSubset.data,"order_number","")
        ),
         a!gridTextColumn(
          label:"Source Type",
          field:"expedite_source_type",
          data:index(local!expDataSubset.data,"expedite_source_type","")
        ),
         a!gridTextColumn(
          label:"Item Number",
          field:"item_number",
          data:index(local!expDataSubset.data,"item_number","")
        ),
         a!gridTextColumn(
          label:"Item Description",
          field:"item_description",
          data:index(local!expDataSubset.data,"item_description","")
        ),
         a!gridTextColumn(
          label:"Customer Number",
          field:"customer_number",
          data:index(local!expDataSubset.data,"customer_number","")
        ),
         a!gridTextColumn(
          label:"Quantity",
          field:"quantity",
          data:index(local!expDataSubset.data,"quantity","")
        ),
         a!gridTextColumn(
          label:"Mfg Source Org Code",
          field:"mfg_source_org_code",
          data:index(local!expDataSubset.data,"mfg_source_org_code","")
        ),
         a!gridTextColumn(
          label:"Schedule Ship Date",
          field:"curr_scheduled_ship_date",
          data:index(local!expDataSubset.data,"curr_scheduled_ship_date","")
        ),
         a!gridTextColumn(
          label:"Mfg Org Code",
          field:"item_mfg_org_code",
          data:index(local!expDataSubset.data,"item_mfg_org_code","")
        ),
        a!gridTextColumn(
          label:"Ship From",
          field:"ship_from",
          data:index(local!expDataSubset.data,"ship_from","")
        ),
          a!gridTextColumn(
          label:"Status",
          field:"status",
          data:index(local!expDataSubset.data,"status","")
        )
      },
      value: local!expdPagingInfo,
      totalCount: index(local!expDataSubset, "totalCount", 0),
      showWhen: if(index(local!expDataSubset,"totalCount",0)>0,true(),false())
    ),
  }
))

Hello, 

I have a grid field where I am fetching only 20 records into the datasubset and displaying in a paging grid. However, when I go to the next page for larger data sets (eg: 30 records) I still see the old dataset records on the next page. How do I fetch the records dynamically on the next page in a paging grid?

Below is what I have so far: 

a!gridField(
label: "Line Section",
totalCount: if(local!datasubset.totalCount=0,1,local!datasubset.totalCount),
emptyGridMessage: "Please enter a valid number",
columns: {
a!gridTextColumn(
label:"Line Number",
field:"line_number",
data:index(local!dataSubset.data,"line_number","")
),
},
identifiers:index(local!dataSubset.data, "line_id" , "{}"),
value: local!gridSelection,
saveInto: {
local!gridSelection,
a!save(
local!rowData,
index(local!dataSubset.data,
wherecontains(
local!gridSelection.selected,
local!dataSubset.identifiers
),{})
)
},
showWhen: if(local!dataSubset.totalCount >0,true(),false()),
selection:if(local!dataSubset.totalCount >0,true,false)
)

 

and below variable is in load: 
 local!gridSelection: a!gridSelection(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 20,
sort:a!sortInfo(
field:"line_id"
)
),
selected: {}
)

Thanks, 

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Hi bpmnewb ,

    In your code,

    a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Query",
    saveInto: {
    a!save(local!dataSubset,rule!GetData(ri!number,local!pagingInfo))
    },
    style: "NORMAL"
    )
    },
    secondaryButtons: {}
    )

    Your local!dataSubset should be inside a with() and the local!pagingInfo should be same as local!gridSelection.pagingInfo.

    So you have to use a todatasubset(local!dataSubset,local!gridSelection.pagingInfo) inside your with() function and save it in another local variable say 'local!gridData'.

    Then replace local!dataSubset with local!gridData at all places inside your a!gridField().

    The code should be like:

    with(

    local!gridData:todatasubset(local!dataSubset,local!gridSelection.pagingInfo),

    a!gridField(/*Replace local!dataSubset with local!gridData at all places*/)

    )

  • Hi ,

    I am now able to implement pagination in grid field with no issues. However, I do have an issue in saving the entire selected row data in a grid. As I am using a form layout and displaying the gridfield in with(), I am not able to display another section layouts dependent on the grid field selection. How do I wrap multiple UI components in a with()? Eg: gridfield and multiple section layouts in a form layout

    Thanks,
  • 0
    Certified Lead Developer
    in reply to bpmnewb

    Are you able to save your grid row data in a local variable or a rule input upon selecting a particular row?

  • Hi ,
    Yes, I am able to save the grid selected row data into a local variable (local!rowData). I would need to display the entire selected row data in a section layout which I am not able to do so as I have a grid field (data subset on search button) within a section layout and not able to display selected row data in another section layout within as below:

    a!sectionLayout(
    contents: {
    a!gridField(
    label: "Expedite Line Section",
    totalCount: if(local!datasubset.totalCount=0,1,local!datasubset.totalCount),
    emptyGridMessage: "Please enter a valid number order number to search for eligible lines ",
    columns: {
    a!gridTextColumn(
    label:"Line Number",
    field:"line_number",
    data:index(local!datasubset.data,"line_number","")
    ),
    a!gridTextColumn(
    label:"Order Number",
    field:"order_number",
    data:index(local!datasubset.data,"order_number","")
    )
    },
    identifiers:index(local!datasubset.data, "line_id" , "{}"),
    value: local!gridSelection,
    saveInto: {
    local!gridSelection,
    a!save(
    local!rowData,
    index(local!datasubset.data,
    wherecontains(
    local!gridSelection.selected,
    local!datasubset.identifiers
    ),{})
    )
    },
    showWhen: if(index(local!datasubset,"totalCount","") >0,true(),false()),
    selection:if(index(local!datasubset,"totalCount","") >0,true,false)
    ),
    a!textField(
    label: "Row Data",
    value: local!rowData
    )
    }
    )

    As above, I can see the selected row data set in the text field but I would need to display it in another section layout.

    Thanks,
  • 0
    Certified Lead Developer
    in reply to bpmnewb
    Declare your local!rowData inside load and then see. I think it should work then.
Reply Children
No Data