I have a display screen that shows a list of items waiting to be acknowledged by technicians. If the page isn’t acknowledged, then the page is escalated up to the next level. The display uses a DataGrid and when the number of items exceeds the displayable rows on the DataGrid, it uses pagination functions to create multiple pages for viewing the other items. When an ArrayCollection is sliced for each page, it causes an issue with sorting. When the data was sorted by level and datetime, it would only sort on the current slice of data, even if I sorted the ArrayCollection before slicing the data. It didn’t seem to matter that I was creating a new ArrayCollection when I was doing the slice, the result was the same, until I figured out the obvious solution.
acMainArray.source.sortOn(["MessageLevel"], [Array.DESCENDING | Array.NUMERIC]); acMainArray.refresh(); // Sort the Pages based on MessageLevel and PageReceivedDateTime acPagnationArray= new ArrayCollection(acMainArray.source); // Split the main ArrayCollection based on the number of pages and current paging index. acPagnationArray= new ArrayCollection(acPagnationArray.source.slice((pagingPageIndex * pagingPageSize),(pagingPageIndex * pagingPageSize) + pagingPageSize)); acPagnationArray.sort = pageSort; acPagnationArray.refresh();
The easy step is to sortOn the original ArrayCollection on the source. Then pass the source into the new ArrayCollection that will be used to create the pages. I do a sort on the sliced ArrayCollection, just to be sure that both the level and DateTime stamp are being sorted. However, I can just do the complete sort on the two items, with a DESCENDING NUMERIC sort on the first and skip the sort after the slice.
acPagingEscalation.source.sortOn(["MessageLevel", "PageReceivedDateTime"], [Array.DESCENDING | Array.NUMERIC, Array.DESCENDING]); acPagingEscalation.refresh();
It seems that most times in programming, the solution is so simple that you wonder why you didn’t find it earlier.
About DeanLogic
Dean has been playing around with programming ever since his family got an IBM PC back in the early 80's. Things have changed since BASICA and Dean has dabbled in HTML, JavaScript, Action Script, Flex, Flash, PHP, C#, C++, J2ME and SQL. On this site Dean likes to share his adventures in coding. And since programming isn't enough of a time killer, Dean has also picked up the hobby of short film creation.
Thanks.But i am using item rendrer in drgataid and i want to edit like textInput at particular location .And if i am using editedItemPosition it shows whole XML(that is used in dataprovider) in text box .So if you have any solution then please help.
I have found that the editItem Renderer is a bit flaky in the datagrid. I would suggest having a pop-up window for editing when a person clicks on the row item. That way you can just get the XML node you are working with and then edit the XML.
Of course, I would probably put the XML into an Array and work with it there.