私はいくつかのカスタムコンポーネントを使用してFlexアプリケーションを構築しています。私はanswer hereをテンプレートとして使って、火花データグリッドでsortByColumn
にしようとしています。私は、機能に次のように使用しようとすると、Custom Spark DataGridの未定義メソッド "sortByColumns"?
myGrid.sortByColumns(0,true);
私はエラーを取得する:
1061: Call to a possibly undefined method sortByColumns through a
reference with static type com.components:MyReportGrid.
このエラーを削除する方法を誰もが知っていますか? MyReportGrid
はどういうわけかスパークコンポーネントの正しい場所をマスキングしていますか?また、invalidateCell()などの他の関数を使用しているときに「未定義のメソッド」エラーが発生し、このエラーに関連するかどうかは不明です。
マイデータグリッドは次のようになります。
次のようにMYCOLUMNがクラスである...
<components:MyReportGrid id="myGrid" dataProvider="{_myData}"...>
<components:columns>
<fx:Array>
<supportClasses:MyColumn ... />
<supportClasses:MyColumn ... />
<supportClasses:MyColumn ... />
...
:
import spark.components.gridClasses.GridColumn;
public class MyColumn extends GridColumn
{
...
public function MyColumn(headerText:String="header" width:Number=100 ...)
{
this.headerText=headerText;
...
}
}
とMyReportGridは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="400" height="300">
import com.components.myClasses.MyColumn;
import com.itemRenderers.myItemRenderer;
import mx.collections.ArrayCollection;
import mx.collections.ArrayList;
import mx.collections.ListCollectionView;
import spark.components.gridClasses.GridColumn;
...
<s:DataGrid width="100%" ... />
</s:Group>
は 'void'ことが第一溶液中sortByColumnsのための型を返すべきでしょうか?また、 'myGrid.sortByColumns(...);' a typo?最初の解決策では 'sortByColumns(...);'にする必要がありますか? – ggkmath
戻り値の型の例を変更しました。あなたの 'MyReportGrid'を埋め込んだアプリケーションのどこでも' myGrid.sortByColumns(); 'を呼び出す必要があります。この例では、 'MyReportGrid'の呼び出しを' DataGrid'に含まれています。 –
Dennisさん、ありがとうございます。 – ggkmath