[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.1

Datagrid pagining with count

Asked by DIGITALUnderworld in Adobe Flex

Tags: Adobe Flex 3

I am trying to get my datagrid paging to work 100%:

The paging part is working, but I need the display of items: "Viewing Laerts 1-25 of 500" to display right.
I need to be able to click "view All' and all records return in the data grid and scroll.

CODE:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                        layout="absolute"
                        creationComplete="InitApp()">

<mx:VBox width="600" height="400"
             paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" verticalScrollPolicy="off" horizontalScrollPolicy="off">

      <mx:Script>
            <![CDATA[
                  import mx.collections.ArrayCollection;
                  import mx.events.ItemClickEvent;
                  import mx.controls.Button;
                  import mx.controls.Alert;
                  
                  [Bindable]
                  public var myData:ArrayCollection = new ArrayCollection();
                  
                  public var orgData:ArrayCollection = new ArrayCollection();
                  
                  [Bindable]
                  public var nav:ArrayCollection = new ArrayCollection();
                  
                  /* Records per page */
                  public var pageSize:uint = 25;
                  /* Number of pages per view */
                  public var navSize:uint = 10;
                  private var index:uint = 0;
                  private var navPage:uint = 1;
                  
                  /* Test data */
                  private function InitApp():void
                  {
                        for( var x:uint = 1; x <= 500; x++ )
                        {
                              var obj:Object = new Object();
                              obj.Icon = x.toString(); /* Needs to be an icon image */
                              obj.Status = "Pending";
                              obj.DateTime = "11/" + x.toString() + "/2008";
                              obj.Artifact = "Artifact " + x.toString();
                              obj.Owner = "Mark Johnson";
                              obj.MarkedBy = "Rick Gerald";
                              obj.Reason = "Illegal Content"; /* Requires Tool Tip */
                              
                              orgData.addItem(obj);
                        }
                        refreshDataProvider(index);
                        createNavBar(Math.ceil(orgData.length/pageSize));
                  }
                  
                  /* Create pagination */
                  private function createNavBar(pages:uint = 1,set:uint = 0):void
                  {
                        nav.removeAll();
                        if( pages > 1 )
                        {
                              nav.addItem({label:"< Previous",data:0});
                        }
                              
                              for( var x:uint = 0; x < navSize; x++)
                              {
                                    var pg:uint = x + set;
                                    nav.addItem({label: pg + 1,data: pg});
                              }
                              if( pg < pages - 1 )
                              {
                                    nav.addItem({label:"Next >",data:pg + 1});
                              }
                        }
                  
                  /* Refresh data per page groups */
                  private function navigatePage(event:ItemClickEvent):void
                  {
                        refreshDataProvider(event.item.data);
                        var lb:String = event.item.label.toString();
                        if( lb.indexOf("<") > -1 || lb.indexOf(">") > -1 )
                        {
                              createNavBar(Math.ceil(orgData.length/pageSize),event.item.data);
                        }
                        
                  }
                  
                  private function refreshDataProvider(start:uint):void
                  {
                        myData = new ArrayCollection( orgData.source.slice((start * pageSize),(start * pageSize) + pageSize) );
                  }
                  
                  /* public static function getDefaultImage(group:String, type:String):Object{
                        var stuff:Array = StyleManager.selectors;
                        var css:CSSStyleDeclaration = StyleManager.getStyleDeclaration("." + getIconStyleName(group) + type);
                        if (css == null)
                              css = StyleManager.getStyleDeclaration(".informationIcon" + type);
                        var img:Object = css.getStyle("borderSkin");
                        return img;
                  } */
                  
                  /* Viewing pages */
                  [Bindable]
                  public var startAlert:uint;
                  [Bindable]
                  public var endAlert:uint;
                  [Bindable]
                  public var totalAlert:uint;
                  
                  private function viewingAlerts ():void {
                        startAlert == ((navPage - 1) * pageSize + 1);
                        endAlert == ((navPage - 1) * pageSize + pageSize);
                        totalAlert == myData.length;
                  }
                  
                  /* private function handleDeptChange():void
            {
                myData.filterFunction = filterStatus;
                myData.refresh();
            }
           
            private function filterStatus(item:Object):String {

            } */
            ]]>
      </mx:Script>

      <mx:Label text="Content Alerts"/>
      <mx:HBox width="100%">
            <mx:Label id="veiwingAlertsLabel" text="Viewing Alerts {startAlert}-{endAlert} of {totalAlert}"/>
            <!--
            <mx:Spacer width="40%"/>
            <mx:Label id="filterByLabel" text="Filter by:"/>
            <mx:LinkButton label="Unprocessed"/>
            <mx:VRule height="20"/>
            <mx:LinkButton label="Processed"/>
            <mx:VRule height="20"/>
            <mx:LinkButton label="All"/>
            -->
      </mx:HBox>
      <mx:DataGrid id="contentAlertDataGrid" dataProvider="{myData}" width="100%" height="100%" verticalScrollPolicy="on" horizontalScrollPolicy="off"/>
      <mx:HRule width="100%"/>
      <mx:HBox width="100%">
            <mx:LinkButton id="viewAllLinkBtn" label="View All"/>
            <mx:VRule height="20"/>
            <mx:LinkBar id="pageNav" itemClick="navigatePage(event)" dataProvider="{nav}" width="{contentAlertDataGrid.width}"/>
      </mx:HBox>
</mx:VBox>
</mx:Application>

[+][-]11/13/08 04:06 PM, ID: 22956291Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Adobe Flex
Tags: Adobe Flex 3
Sign Up Now!
Solution Provided By: evcr
Participating Experts: 1
Solution Grade: B
 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_2_20070628