Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    listgrid sort

    We currently have our own mechanism for listgrid paging where we only send over the data allowed per page (when they click on some menus like 10 20 30 etc). The problem is that since we are using the client-side sorting, it will only sort the data currently present. What we would like to do is force sorting on the full list which we have on the server-side and then again, return only the number of data allowed per page.

    I guess the first question would be how to get the listgrid to issue a call to the server when the user has changed the sorting.

    #2
    Use a ResultSet as the data model even though you have your own paging UI. This will also handle client-side filtering as well as cache sync.

    Comment


      #3
      Could you provide more details? I read the documentation for ResultSet and what I got from it was that ResultSets are used automatically - so what am I missing? Here's a snippet of a listgrid code - we call fetch() on the listgrid when we need the data and according to the documentation, this would result in a ResultSet being created.

      Code:
      isc.DataSource.create({ID:"result$ds",
      fields:
      [{name:"cwPK__",primaryKey:true},
      {name:"EventID"},
      {name:"NodeId1"},
      {name:"EVENT_TIME",required:true},
      {name:"EVENT_SOURCE",required:true},
      {name:"EVENT_SEVERITY",required:true},
      {name:"EVENT_CODE",required:true},
      {name:"userId"},
      {name:"logTransactionId"},
      {name:"DESCRIPTION"}]),
      
      isc.ListGrid.create({
      fastCellUpdates:false,
      groupStartOpen:"first",
      wrapCells:true,
      fixedRecordHeights:false,
      dataSource:"result$ds",
      validateOnChange:true,
      ID:"result",
      headerHeight:30,
      hoverStyle:"CwHoverStyle",
      neverValidate:true,modalEditing:true,canSelectText:true,selectOnEdit:true,willHandleErrors:true,autoFetchData:false,canSort:true,selectionProperty:"$isCwSelected",headerButtonProperties:{wrap:true},fields:
      [{title:"Id",type:"integer",
      displayField:"$cwEventID",sortByDisplayField:false,
      neverValidate:true,validateOnChange:false,_constructor:"TextItem",
      type:"text",criteriaField:"EventID",name:"EventID",align:"left",width:"64"},
      {title:"NODE ID",neverValidate:true,type:"text",criteriaField:"NodeId",
      name:"NodeId",align:"left",width:"100"},
      {title:"Timestamp",type:"text",canEdit:false,align:"left",width:"110"},
      {title:"Severity",valueMap:{"0":"Debug","1":"Information","2":"Warning","3":"Error","4":"Fatal Error"},editorType:"SelectItem",name:"EVENT_SEVERITY",align:"left",validateOnChange:true,width:"78"}],canEdit:false});}

      Comment


        #4
        Also, I do see that when not all data is present, the sort goes to the server to retrieve more data - but in our "paging", the data for that particular page is already in cache

        Could i just set useClientSorting to false, allow the server-side to return a new set of 10 or 20 rows (whatever the paging size currently is), then when dataArrived is called, call sort() on the listgrid? I'm thinking the sortSpecifier would come from listGrid.getSort ()
        Last edited by acarur01; 27 Aug 2012, 05:39.

        Comment


          #5
          A ResultSet is automatically created if you call fetchData(). We're not sure how you've attempted to implement your own paging (you mention that a page is in cache, but clearly it's not in the ResultSet), but note that calling setData() with a simple Array will remove the ResultSet.

          You can turn off all these behaviors via flags like useClientSorting:false at the cost of severely degraded performance.

          Overall, link-based paging has a number of serious drawbacks relative to the default paging mode used by grids and we would not recommend implementing it.

          Comment


            #6
            We implement our "paging" by only sending a startRow of 0, endRow of pagingSize when the fetch request comes in every time. We do the calculation in the server-side for what page number has been requested.

            The listgrid thinks there isn't anymore data besides the ones that are already in the browser cache.

            Code:
                  listGrid.fetchData(null, null, {showPrompt:false});
            If you have another suggestion as to how to implement this kind of paging, do let me know. We have this implemented because this is what our clients wanted - to limit the number of data being shown by page control.

            Comment


              #7
              At this point we have no idea what your implementation looks like or what it's purpose might be.

              The ListGrid normally pages on scroll, so are you triggering paging in some other way? How?

              Are you transforming the automatically sent startRow and endRow? In what layer?

              What do you mean by "limit the number of data being shown by page control" and why wouldn't you simply use the built-in progressiveLoading strategy for this instead?

              Comment


                #8
                We have a dropdown with enumeration 10 20 30 50 which represents the number of rows to show per "page". We also have a previous/next menu which allows them to show the next batch of data. When the next menu is clicked, we call some server logic that increments the page number then we go back to the browser and call listgrid.fetchData - when the ds request comes in, we gather the information we need - ie. the current page number - if the total rows in the server side is 50 and the current page is 2, and the data size per page is set to 10, then we send rows 10-19, but we set startRow=0, and endRow=9 on the dsresponse
                Attached Files

                Comment


                  #9
                  This is a terrible pattern which is causing you to lose both Adaptive Sort and Adaptive Filter.

                  Our first recommendation remains don't use link-based paging for all the reasons explained before. It does not seem to address your user's wishes either.

                  Second recommendation is don't lie to the ResultSet about row numbers - give it the actual row numbers, and allow it to build up caches and use Adaptive Sort/Filter.

                  Comment


                    #10
                    Our users' wish is to maintain the UI that I have shown in the screenshot. Other UI's such as Tracker (Mantis) have paging, why can't we? Google search also has paging that look like ours. We cannot remove this feature but we can change how it is written to behave. If you would just tell me how you would implement it if one of your clients asked for it, it would be more useful than stating that you think it's not what the client wants.

                    Comment


                      #11
                      This is in response to my understanding that you think I should remove such feature in our product

                      Originally posted by acarur01 View Post
                      Our users' wish is to maintain the UI that I have shown in the screenshot. Other UI's such as Tracker (Mantis) have paging, why can't we? Google search also has paging that look like ours. We cannot remove this feature but we can change how it is written to behave. If you would just tell me how you would implement it if one of your clients asked for it, it would be more useful than stating that you think it's not what the client wants.

                      Comment


                        #12
                        When clients have asked for it, we have pointed out the drawbacks, encouraged them to talk to their users, and they have found out that their users actually prefer the default behavior, for all the reasons we listed.

                        Usually what has happened is that the end users said something non-specific like "we don't want to see so much data" and the developers have incorrectly decided that this implies link-based paging.

                        So we are trying to do you the same favor.

                        As far as how to implement it anyway, again, giving the ResultSet false row indices or you break Adaptive Sort and Adaptive Filter. You can trigger loading of specific row ranges by just asking the ResultSet for those rows via getRange().

                        Once the ResultSet knows the actual row ranges and actual totalRows you will need to force the scrollbar to hide via setting overflow:hidden on the body.

                        Comment


                          #13
                          hide the scrollbar? Is this because then if the user scrolls down, the listgrid will attempt to fetch more? that's the fetching we were trying to avoid btw so this would work but what about listgrids that are specifying height only big enough to accommodate 10 rows but there are 20 rows per page? Normally scrollbars are not ideal but we do have clients with this scenario.

                          Comment


                            #14
                            Looks like you are slowly discovering the reasons this approach is a bad idea - you've just hit point #2 in our list of serious drawbacks with link-based paging.

                            If you really really want to mix scrolling and link-based paging (which is basically the worst of both worlds) you would need to have a ResultSet that you maintain separately from the grid, and feed slices of records from this ResultSet to the grid via setData() with simple Arrays.

                            For example, if the ListGrid is 10 rows tall, setData() with an Array of 20 rows will cause scrolling for just that many rows, without fetching any new data.

                            This will destroy all Adaptive Filtering and Adaptive Sort and cause you to implement your own handling for filter and sort in general.

                            Comment


                              #15
                              We've decided to bring back our server-side sorting logic from legacy code. Where can I set useClientSorting on the resultset? in dataArrived?

                              Comment

                              Working...
                              X