<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Paging reset to 1 on button click, if update happen on another page</title><link>https://community.appian.com/discussions/f/user-interface/20622/paging-reset-to-1-on-button-click-if-update-happen-on-another-page</link><description>having issue on the APN 20.1 with gridFiled, Paging reset to original page on UPDATE DATA button click, if the selected row is update from next page.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Paging reset to 1 on button click, if update happen on another page</title><link>https://community.appian.com/thread/80388?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 19:33:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6463d4fe-6379-409a-9a34-623c6e24e2e6</guid><dc:creator>Pari</dc:creator><description>&lt;p&gt;Thanks Mike,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have tried the&amp;nbsp;local pagingInfo, but might have missed something,. Cool have tried it on main code and looks to be working&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging reset to 1 on button click, if update happen on another page</title><link>https://community.appian.com/thread/80387?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 19:20:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:50d59c26-40c7-422b-9266-c1f71599dae0</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Your &amp;quot;Update Data&amp;quot; button is doing several confusing things.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;removing rows from employeeDS where the id is in the selected employee list (makes sense)&lt;/li&gt;
&lt;li&gt;overwriting employeeDS with the remaining employeeDS array appended with selected employees, essentially reversing #1&lt;/li&gt;
&lt;li&gt;finally you&amp;#39;re overwriting employeeDS (again) with a todatasubset() call on top of employeeDS to sort it by id&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It seems like a lot of unnecessary complexity, though i guess that depends on your use case.&lt;/p&gt;
&lt;p&gt;I believe a!gridField (when using fv!pagingInfo) will try to adjust to structural changes to the source dataSubset by reverting to a startIndex of 1 - this is to prevent pink errors from occurring when you do things like removals or filtering when on any page after 1.&lt;/p&gt;
&lt;p&gt;If you want to more tightly control this, I&amp;#39;d suggest you use an external pagingInfo variable and control it yourself.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!selection,
  local!selectedEmployees,
  local!employeeDS: {
    {id: 11,name: &amp;quot;Elizabeth Ward&amp;quot;,dept: &amp;quot;Engineering&amp;quot;,startDate: today() - 500},
    {id: 22,name: &amp;quot;Michael Johnson&amp;quot;,dept: &amp;quot;Finance&amp;quot;,startDate: today() - 100},
    {id: 33,name: &amp;quot;John Smith&amp;quot;,dept: &amp;quot;Engineering&amp;quot;,startDate: today() - 1000},
    {id: 44,name: &amp;quot;Diana Hellstrom&amp;quot;,dept: &amp;quot;Engineering&amp;quot;,startDate: today() - 1200},
    {id: 55,name: &amp;quot;Francois Morin&amp;quot;,dept: &amp;quot;Sales&amp;quot;,startDate: today() - 700},
    {id: 66,name: &amp;quot;Maya Kapoor&amp;quot;,dept: &amp;quot;Sales&amp;quot;,startDate: today() - 1400},
    {id: 77,name: &amp;quot;Anthony Wu&amp;quot;,dept: &amp;quot;Human Resources&amp;quot;,startDate: today() - 300}
  },
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 3,
    sort: a!sortInfo(
      field: &amp;quot;id&amp;quot;,
      ascending: true()
    )
  ),
  
  {
    a!richTextDisplayField(
      label: &amp;quot;&amp;quot;,
      labelPosition: &amp;quot;COLLAPSED&amp;quot;,
      value: {
        a!richTextHeader(
          text: &amp;quot;Paging reset to 1 on &amp;quot;&amp;quot;UPDATE DATA&amp;quot;&amp;quot; button click, if update happen on another page&amp;quot;
        )
      }
    ),
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!gridField(
              label: &amp;quot;Employee Directory&amp;quot;,
              data: todatasubset(
                local!employeeDS,
                local!pagingInfo
              ),
              pagingSaveInto: local!pagingInfo,
              columns: {
                a!gridColumn(
                  label: &amp;quot;Name&amp;quot;,
                  sortField: &amp;quot;name&amp;quot;,
                  value: fv!row.name
                ),
                a!gridColumn(
                  label: &amp;quot;Department&amp;quot;,
                  sortField: &amp;quot;dept&amp;quot;,
                  value: fv!row.dept
                ),
                a!gridColumn(
                  label: &amp;quot;Start Date&amp;quot;,
                  sortField: &amp;quot;startDate&amp;quot;,
                  value: fv!row.startDate,
                  align: &amp;quot;END&amp;quot;
                )
              },
              /*pageSize: 3,*/
              selectable: true,
              selectionValue: local!selection,
              selectionSaveInto: {
                local!selection,
                a!save(
                  local!selectedEmployees,
                  index(
                    fv!selectedRows,
                    length(fv!selectedRows),
                    null
                  )
                ),
                a!save(
                  local!selection,
                  index(
                    save!value,
                    length(save!value),
                    null
                  )
                )
              }
            )
          }
        )
      },
      stackWhen: {
        &amp;quot;PHONE&amp;quot;,
        &amp;quot;TABLET_PORTRAIT&amp;quot;
      }
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          label: &amp;quot;Update Data&amp;quot;,
          saveInto: {
            a!save(
              local!employeeDS,
              remove(
                local!employeeDS,
                wherecontains(
                  touniformstring(local!selectedEmployees.id),
                  touniformstring(local!employeeDS.id)
                )
              )
            ),
            a!save(
              local!employeeDS,
              append(
                local!employeeDS,
                local!selectedEmployees
              )
            ),
            a!save(
              local!employeeDS,
              todatasubset(
                arrayToPage: local!employeeDS,
                pagingConfiguration: a!pagingInfo(
                  startIndex: 1,
                  batchSize: 10,
                  sort: a!sortInfo(
                    field: &amp;quot;id&amp;quot;,
                    ascending: true
                  )
                )
              ).data
            )
          },
          submit: false,
          style: &amp;quot;NORMAL&amp;quot;
        )
      },
      align: &amp;quot;START&amp;quot;
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging reset to 1 on button click, if update happen on another page</title><link>https://community.appian.com/thread/80386?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 19:07:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:515ab3ee-b4fe-460b-ac36-e05e4d93a618</guid><dc:creator>Pari</dc:creator><description>&lt;p&gt;Yes thats correct. it should not revert to first page, even thought the data is updated with some&amp;nbsp;button clicks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging reset to 1 on button click, if update happen on another page</title><link>https://community.appian.com/thread/80385?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 19:06:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2c6217b2-4ab1-42bd-af4d-84fc971ef8c5</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Thanks for editing to include a Code Box.&lt;/p&gt;
&lt;p&gt;As far as your issue: are you saying you &lt;strong&gt;don&amp;#39;t&lt;/strong&gt; want it to revert to the first plage any time the button is clicked?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging reset to 1 on button click, if update happen on another page</title><link>https://community.appian.com/thread/80384?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 19:03:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:61c54e3c-cd3b-43ab-ba61-d5ab933ebead</guid><dc:creator>Pari</dc:creator><description>&lt;p&gt;Hey Mike,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Its standalone code, so you can play with it. Use case when you&amp;nbsp;click on the next page on the grid. and select some value and click on button. the grid&amp;nbsp;resets from current page and&amp;nbsp;goes back to&amp;nbsp;initial&amp;nbsp;page.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging reset to 1 on button click, if update happen on another page</title><link>https://community.appian.com/thread/80383?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 18:51:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b372bcba-c67a-4127-9b85-cdb507d2704d</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;two quick things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;code this long is much much easier for us to read if you use the &amp;quot;Code Box&amp;quot; functionality available in the &amp;quot;Insert&amp;quot; menu, sub-heading &amp;quot;Insert Code&amp;quot;.&amp;nbsp; It uses a friendly font size and style for reading through code, as well as preserving indentation and some degree of formatting, and keeps code from blowing out a post&amp;#39;s length to require a lot of scrolling such as has happened here.&lt;/li&gt;
&lt;li&gt;What exactly are you trying to do, and what is happening instead?&amp;nbsp; I&amp;#39;m a little unclear, though it seems like you&amp;#39;re saying you want the start index to revert to 1 when the user uses that button.&amp;nbsp; Can you confirm?&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>