Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SortItemsOn method (sort data by more fields)

Guest
Jun 23, 2014 Jun 23, 2014

Hello,

I have a datagrid control that i want to be sorted by two fields instead one. (it works fine with one filed though)

I am using the method SortItemsOn() which according the documentation, Sorts the elements of the current data provider by one or more of its fields.

However if i add two fields i get some weird result. e.g.

datagrid.sortItemsOn("Field1 Field2", Array.NUMERIC);

The Field1 is of date data type and the Field2 is textual field so maybe that's why it does not give the expected result.

Thank you so much

TOPICS
ActionScript
242
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 24, 2014 Jun 24, 2014

i don't know of any for flash.  there are several for flex.

but for flash, just make your own using a custom sort. eg,

function sortGridF():void{

    var dp:DataProvider = datagrid.dataProvider;

    dp.sortOn(["Field1, Field2"], Array.NUMERIC);

}

p.s. please mark correct/helpful responses.

Translate
Community Expert ,
Jun 24, 2014 Jun 24, 2014

that method only accepts one field.  to sort on two fields you'll need to create your own sorter.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 24, 2014 Jun 24, 2014

Hmm then why the documentation says that it "Sorts the elements of the current data provider by one or more of its fields"

SelectableList - Adobe ActionScript® 3 (AS3 Flash) API Reference

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2014 Jun 24, 2014

couldn't tell you that but it only accepts a string in the first parameter and there's no way to indicate multiple columns with one string.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 24, 2014 Jun 24, 2014

I see. Ok could you please show me or give me a link where i can see an example of multiple fields sorter? Would be greatly appreciated. Thx

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2014 Jun 24, 2014
LATEST

i don't know of any for flash.  there are several for flex.

but for flash, just make your own using a custom sort. eg,

function sortGridF():void{

    var dp:DataProvider = datagrid.dataProvider;

    dp.sortOn(["Field1, Field2"], Array.NUMERIC);

}

p.s. please mark correct/helpful responses.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines