I’m wondering why is it my search result is null after I press search button. After I press search, the datagrid is blank. But I ever test my service and it’s working.

Anyone has any idea how to solve it? So sorry I’m totally new to FLEX… >.<

Below is my code…

<?xml version=”1.0″ encoding=”utf-8″?>

<s:WindowedApplication xmlns:fx=”http://ns.adobe.com/mxml/2009

                       xmlns:s=”library://ns.adobe.com/flex/spark”

                       xmlns:mx=”library://ns.adobe.com/flex/mx”

                       xmlns:productbasicservice=”services.productbasicservice.*”

                       width=”1024″ height=”768″>

    <fx:Script>

        <![CDATA[

            import mx.collections.ArrayCollection;

            import mx.controls.Alert;

            import mx.controls.TextInput;

            import mx.events.DataGridEvent;

            import mx.events.FlexEvent;

            import mx.rpc.AsyncToken;

           

            import valueObjects.Product_basic;

           

            protected function dataGrid_creationCompleteHandler(event:FlexEvent):void

            {

                getProduct_basic_pagedResult.token = productbasicService.getProduct_basic_paged();

 

            }

            protected function saveClick(event:MouseEvent):void

            {

                productbasicService.commit();

            }

           

            protected function revertData(event:MouseEvent):void

            {

                productbasicService.revertChanges();

            }

           

           

            protected function searchData(event:MouseEvent):void

            {

                var searchStr:String = searchbox.toString();

               

                searchProduct_basicResult.token = productbasicService.searchProduct_basic(searchStr);

                dataGrid.dataProvider = searchProduct_basicResult.lastResult;

            }

           

        ]]>

    </fx:Script>

    <fx:Declarations>

        <s:CallResponder id=”getAllProduct_basicResult”/>

        <productbasicservice:ProductbasicService id=”productbasicService”

                                                 fault=”Alert.show(event.fault.faultString + ‘\n’ + event.fault.faultDetail)”

                                                 showBusyCursor=”true”/>

        <s:CallResponder id=”getProduct_basic_pagedResult”/>

        <s:CallResponder id=”searchProduct_basicResult”/>

        <!– Place non-visual elements (e.g., services, value objects) here –>

    </fx:Declarations>

    <mx:DataGrid id=”dataGrid” x=”11″ y=”61″ width=”1003″ height=”557″

                 creationComplete=”dataGrid_creationCompleteHandler(event)”

                 dataProvider=”{getProduct_basic_pagedResult.lastResult as ArrayCollection}” editable=”true”>

        <mx:columns>

            <mx:DataGridColumn width=”200″ dataField=”id” editable=”false” headerText=”ID”/>

            <mx:DataGridColumn dataField=”name” headerText=”name”/>

            <mx:DataGridColumn width=”200″ dataField=”price” headerText=”Price”/>

            <mx:DataGridColumn dataField=”description” headerText=”description”/>

        </mx:columns>

    </mx:DataGrid>

    <s:Button x=”849″ y=”22″ label=”Save” click=”saveClick(event)”/>

    <s:Button x=”944″ y=”22″ label=”Revert” click=”revertData(event)”/>

    <s:TextInput x=”14″ y=”22″ width=”367″ id=”searchbox”/>

    <s:Button id=”button” x=”389″ y=”22″ label=”Search” click=”searchData(event)”/>

</s:WindowedApplication>

 

I have added my own data service operation in the php file called searchProduct_basic(searchStr). Basically this function return the object of the search result.

|||

Maybe lastResult isn’t an ArrayCollection.  Check your resultFormat setting.

|||

It’s the same for lastResult as ArrayCollection.

            protected function searchData(event:MouseEvent):void

            {

                var searchStr:String = searchbox.toString();

               

                searchProduct_basicResult.token = productbasicService.searchProduct_basic(searchStr);

                dataGrid.dataProvider = searchProduct_basicResult.lastResult;

            }

For you information, the searchProduct_basic(searchStr) would return Product_basic object. >.<

Related posts:

  1. Datagrid colum item renderer HELP!!!!!
  2. Datagrid columns widths
  3. IOS Datagrid problem
  4. StageWebView compiling bug?
  5. Error when a DataGrid is edited

Related posts brought to you by Yet Another Related Posts Plugin.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 free icons download Suffusion theme by Sayontan Sinha

Featuring Recent Posts WordPress Widget development by YD