Thread Rating:
  • 355 Vote(s) - 2.75 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sort of RecordView
11-21-2012, 10:23 AM,
#1
Sort of RecordView
Hi, everybody

When RecordView is sorted, the specific Record must not be sorted.
For example,
----------------------------------------
LOTID | HOLD | RUN | WAIT
----------------------------------------
AAAA | 200 | 100 | 50
BBBB | 300 | 50 | 30
TOTAL | 500 | 150 | 80
----------------------------------------
the Record of TOTAL must not be sorted and it must be always in the bottom of RecordView.
I tried to use RecordSort object but it did not work as I wished.



11-21-2012, 02:04 PM,
#2
RE: Sort of RecordView
Which column would you like to sort by?
How did you try to do that?
It may help if you show us the code we can reproduce the problem.
11-21-2012, 02:23 PM,
#3
RE: Sort of RecordView
How about this?

Code:
{curl 7.0 applet}

{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField "First", domain = String},
            {RecordField "Last", domain = String},
            {RecordField "Age", domain = int},
            || hidden field
            {RecordField "hidden", domain = int}
        },
        || hidden = 0
        {RecordData First = "Gene", Last = "Smith", Age = 25, hidden = 0},
        {RecordData First = "Fred", Last = "Smith", Age = 29, hidden = 0},
        {RecordData First = "Mike", Last = "Jones", Age = 28, hidden = 0},
        {RecordData First = "Ben", Last = "Abrams", Age = 25, hidden = 0},
        {RecordData First = "Ben", Last = "Smith", Age = 21, hidden = 0},
        {RecordData First = "Sam", Last = "Jones", Age = 22, hidden = 0},
        {RecordData First = "Nigel", Last = "Stevens", Age = 24, hidden = 0},
        {RecordData First = "Bert", Last = "Stevens", Age = 22, hidden = 0},
        {RecordData First = "Pat", Last = "Linden", Age = 27, hidden = 0},
        || hidden = 1
        {RecordData First = "TOTAL", Last = "", Age = 25+29+28, hidden = 1}
    }
}
{let asc?:bool = true}
{let last-sort-column:String = ""}

{def rg = {RecordGrid
              record-source = people,
              height = 10cm,
              automatic-columns? = false,
              {RecordGridColumn "First"},
              {RecordGridColumn "Last"},
              {RecordGridColumn "Age"},

              sort = {RecordSort.from-string "hidden, Age"},
              sort-spec = {proc {rgc:RecordGridColumn}:RecordSort
                              {if last-sort-column != rgc.field-name then
                                  set asc? = true
                              }
                              let rs:RecordSort =
                                  {RecordSort.from-string
                                      "hidden " &
                                      {if asc? then
                                          "asc"
                                       else
                                          "desc"
                                      }
                                      & ", " & rgc.field-name
                                  }
                              || Store column name and sort order.
                              set last-sort-column = rgc.field-name
                              set asc? = not asc?
                              {return rs}
                          }
          }
}
{value rg}
11-21-2012, 03:52 PM, (This post was last modified: 11-21-2012, 03:54 PM by alchimiste.)
#4
RE: Sort of RecordView

The TOTAL record should not be sorted for all columns.


Users want to see the summary record such as TOTAL or AVERAGE.
The summary record usually is located in the bottom of RecordView.

I'm implementing this for the grid component, modified FastRecordGrid.

The source code that I wrote:

def rd = rv[rv.size - 1] || rv is RecordView
set rv.sort = {proc {r1:Record, r2:Record}:int
|| I thnk this code is stupid...Smile
{if r1 == rd then {return 1}}
|| the rest of logics is omitted for explanation
}








Possibly Related Threads...
Thread Author Replies Views Last Post
  RecordView.batch-events? の効果がない umemura 1 2,666 12-10-2013, 03:28 PM
Last Post: umemura
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('652')