<?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 an editable grid, and persisting the data across pages in the UI</title><link>https://community.appian.com/discussions/f/user-interface/21456/paging-an-editable-grid-and-persisting-the-data-across-pages-in-the-ui</link><description>I am looking for a way to page an array of CDTs in an editable grid. The caveat is that I need the data to persist across pages. Has anyone done this before? Some code examples would be great.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Paging an editable grid, and persisting the data across pages in the UI</title><link>https://community.appian.com/thread/83786?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 18:40:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1b81e6b8-ac49-4193-83b5-527c5a1e25d1</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;So quite a few things you&amp;#39;ll have to do.&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp; Either query all the data up front and store it in one location (a local variable), or if that&amp;#39;s going to be a really bad performance hit, then query the first page of the data and store it in that local, and when startindex goes up, you&amp;#39;ll have to grab more data and append it.&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp; Create a SEPARATE local variable that stores the first page of the data.&amp;nbsp; local!queriedData and local!currentGridPageData may be good names.&lt;/p&gt;
&lt;p&gt;3. Populate your grid with the data from the second one, local!currentGridPageData&lt;/p&gt;
&lt;p&gt;4. When you make changes to the row, update the row on BOTH local variables.&lt;/p&gt;
&lt;p&gt;5. Create custom controls that handle your paging and batchsize.&amp;nbsp; This is where this whole idea is kind of nice, because you can use ANYTHING.&lt;/p&gt;
&lt;p&gt;6.&amp;nbsp; When you hit one of the custom controls, page data&amp;nbsp;from the first one and put it into the second one, which puts only part of that data in the grid.&amp;nbsp; Never&amp;nbsp;re-query the data again, or it wipes out the changes you just specified you want to persist.&amp;nbsp; If you don&amp;#39;t have the data you need in local!queriedData, get the next page of data from query and append it to the end ONLY.&amp;nbsp; When you go back to a previous page, you are only paging data for the grid (which goes in the second one) from the data in your first one.&lt;/p&gt;
&lt;p&gt;7.&amp;nbsp; The first localVariable (local!queriedData) will eventually contain all changes across all pages.&amp;nbsp; That needs to be sent to a rule input and saved when the form is submitted.&amp;nbsp; Then that can go to a PV and be written to the DB / External Service.&amp;nbsp; Otherwise, of course, there was no point to this form.&lt;/p&gt;
&lt;p&gt;A bit of work, and you&amp;#39;ll probably eventually be storing all rows of the whole database in local!queriedData, so this is only viable for a small enough dataset.&amp;nbsp; The performance will get really, really bad if this gets really, really big.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging an editable grid, and persisting the data across pages in the UI</title><link>https://community.appian.com/thread/83785?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 18:34:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1027fa6e-e299-4082-8ea6-c6dd2158ffa9</guid><dc:creator>Madhusudan Sharma</dc:creator><description>&lt;p&gt;Then the aforementioned sample code with a small tweak will do the job. Try this with your custom pagination:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!items: {
    {item: &amp;quot;Item 1&amp;quot;, qty: 1},
    {item: &amp;quot;Item 2&amp;quot;, qty: 2},
    {item: &amp;quot;Item 3&amp;quot;, qty: 1},
    {item: &amp;quot;Item 4&amp;quot;, qty: 3},
    {item: &amp;quot;Item 5&amp;quot;, qty: 4}
  },
  a!gridLayout(
    label: &amp;quot;Products&amp;quot;,
    headerCells: {
      a!gridLayoutHeaderCell(label: &amp;quot;Item&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Qty&amp;quot;)
    },
    rows: a!forEach(
      items: local!items,
      expression: a!gridRowLayout(
        contents: {
          a!textField(
            value: local!items[fv!index].item,
            saveInto: local!items[fv!index].item
          ),
          a!integerField(
            value: local!items[fv!index].qty,
            saveInto: local!items[fv!index].qty
          )
        }
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Change the details as per your requirement. Hope it helps.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging an editable grid, and persisting the data across pages in the UI</title><link>https://community.appian.com/thread/83784?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 18:28:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:85bbeffe-8047-4a55-85bb-7ec785379aae</guid><dc:creator>walkers0001</dc:creator><description>&lt;p&gt;It should remain the same, besides the field that the user may update in the grid.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging an editable grid, and persisting the data across pages in the UI</title><link>https://community.appian.com/thread/83783?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 18:25:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c5787718-8664-40ee-af31-6e8284a70758</guid><dc:creator>Madhusudan Sharma</dc:creator><description>&lt;p&gt;Will your array of CDT remain the same? I mean, is there any chance that you&amp;#39;ll be re-loading it with the new data every time you paginate through the grid?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging an editable grid, and persisting the data across pages in the UI</title><link>https://community.appian.com/thread/83782?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 18:02:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:35386c53-1f09-4d30-9e66-44eb1d658865</guid><dc:creator>walkers0001</dc:creator><description>&lt;p&gt;I know that editable grids don&amp;#39;t have OOTB paging, which is why I am trying to build it.&amp;nbsp; By persist, I mean if the user updates fields for a row on one page, and then pages to the next page, and then page back to the previous page, they will still see the data that they updated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Paging an editable grid, and persisting the data across pages in the UI</title><link>https://community.appian.com/thread/83781?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 17:55:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a3580ca1-a975-44fb-95f0-ac907dd151fe</guid><dc:creator>Madhusudan Sharma</dc:creator><description>&lt;p&gt;Editable grids don&amp;#39;t allow pagination. When you say &amp;quot;persist the data across pages&amp;quot;, I&amp;#39;m assuming that you&amp;#39;re updating the data in the grid and want it to stay there. If I understand you correctly, here is&amp;nbsp;the sample code to achieve the task:&amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/21.2/Editable_Grid_Component.html#editable-grid-with-two-rows"&gt;https://docs.appian.com/...editable-grid&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If I misunderstood you, could you please elaborate a little further about your use case? Do you want to create custom pagination? Or do you already have it and want to persist the data when you paginate through it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>