Welcome to Kap Lab Store

Topic "DataFilteringTextInput, Datagrid, & PHP Data Service"


5 Item(s)

per page
I was trying to utilize the DataFilteringTextInput to filter the results of a data service call which is displayed in a datagrid, however, I'm running into a problem. When text is entered, the datagrid is cleared of all data as if no data matches the filter.

Here is my relevant code:

Script:
<![CDATA[
			import fr.kapit.flex.ui.spark.loginBox.event.LoginBoxEvent;
 
			import mx.controls.Alert;
			import mx.events.FlexEvent;
			import mx.rpc.events.ResultEvent;
 
			import mx.logging.ILogger;
			import mx.logging.Log;
 
			protected static const _logger:ILogger = Log.getLogger("flex4ui.DataFilteringTextInput");
 
			[Bindable] private var __filterOnAnyProperty:Boolean = true;
 
 
			public function dispose():void
			{
			}
 
 
			protected function cbFilterOnAll_clickHandler(event:MouseEvent):void
 
			{
				__filterOnAnyProperty = cbFilterOnAll.selected;
 
				if (__filterOnAnyProperty)
				{
					dataFilteringTextInput.filteredProperties = null;
					_logger.info("dataFilteringTextInput.{0} = {1}", "filteredProperties", null);
				}
				else
				{
					dataFilteringTextInput.filteredProperties = [];
					_logger.info("dataFilteringTextInput.{0} = {1}", "filteredProperties", "[]");
				}
 
				cbFilterOnName.selected = __filterOnAnyProperty;
				cbFilterOnAddress.selected = __filterOnAnyProperty;
				cbFilterOnCity.selected = __filterOnAnyProperty;
			}
 
 
 
			protected function filterCheck_clickHandler(event:MouseEvent):void
			{
				var allCheckboxSelected:Boolean = (cbFilterOnName.selected && cbFilterOnAddress.selected && cbFilterOnCity.selected);
 
				if (allCheckboxSelected != cbFilterOnAll.selected)
				{
					cbFilterOnAll.selected = allCheckboxSelected;
					if (allCheckboxSelected)
					{
						cbFilterOnAll_clickHandler(null);
						return;
					}
				}
 
				var filterOn:Array = [];
				if (cbFilterOnName.selected)
				{
					filterOn.push("builder_Name");
				}
				if (cbFilterOnAddress.selected)
				{
					filterOn.push("builder_Address");
				}
				if (cbFilterOnCity.selected)
				{
					filterOn.push("builder_City");
				}
				dataFilteringTextInput.filteredProperties = filterOn;
				_logger.info("dataFilteringTextInput.{0} = [{1}]", "filteredProperties", filterOn);
			}
 
protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
			{
				mSBuilderServices.endpoint = "http://pro-linx.net/app-resources/gateway.php"
				getAllBuilderResult.token = mSBuilderServices.getAllBuilder();
			}
 
		]]>
 
Declarations:
<s:CallResponder id="getAllBuilderResult"/>
		<msbuilderservices:MSBuilderServices id="mSBuilderServices"
											 fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
											 showBusyCursor="true"/>
 
MXML:
<s:Group includeIn="MSC" left="10" top="10" bottom="10" width="50%">
		<s:Label left="0" top="10" fontFamily="Futura" fontSize="20" text="Builders"/>
		<ui:DataFilteringTextInput id="dataFilteringTextInput" right="10" width="240"
								   dataProvider="{getAllBuilderResult.lastResult}"
								   prompt="Filter"
								   skinClass="fr.kapit.flex.ui.spark.dataFilteringTextInput.DataFilteringTextInputSkin"/>
 
		<s:DataGrid id="dataGrid" left="0" right="0" top="65" bottom="0"
					creationComplete="dataGrid_creationCompleteHandler(event)">
			<s:columns>
				<s:ArrayList>
					<s:GridColumn visible="false" dataField="builder_id" headerText="builder_id"></s:GridColumn>
					<s:GridColumn dataField="builder_Name" headerText="Name"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_State"
								  headerText="builder_State"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_County"
								  headerText="builder_County"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_Email"
								  headerText="builder_Email"></s:GridColumn>
					<s:GridColumn dataField="builder_Address" headerText="Address"></s:GridColumn>
					<s:GridColumn dataField="builder_City" headerText="City"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_Phone"
								  headerText="builder_Phone"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_Zip" headerText="builder_Zip"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_Website"
								  headerText="builder_Website"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_ContactName"
								  headerText="builder_ContactName"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_ContactNumber"
								  headerText="builder_ContactNumber"></s:GridColumn>
					<s:GridColumn visible="false" dataField="builder_Username"
								  headerText="builder_Username"></s:GridColumn>
				</s:ArrayList>
			</s:columns>
			<s:AsyncListView list="{getAllBuilderResult.lastResult}"/>
		</s:DataGrid>
		<s:HGroup left="5" top="30" width="100%" gap="20">
			<s:CheckBox id="cbFilterOnAll" label="All" fontWeight="bold"
						selected="{__filterOnAnyProperty}" click="cbFilterOnAll_clickHandler(event)"/>
			<s:CheckBox id="cbFilterOnName" label="Name" fontWeight="bold"
						selected="{__filterOnAnyProperty}" click="filterCheck_clickHandler(event)"/>
			<s:CheckBox id="cbFilterOnAddress" label="Address" fontWeight="bold"
						selected="{__filterOnAnyProperty}" click="filterCheck_clickHandler(event)"/>
			<s:CheckBox id="cbFilterOnCity" label="City" fontWeight="bold"
						selected="{__filterOnAnyProperty}" click="filterCheck_clickHandler(event)"/>
		</s:HGroup>
 
		</s:Group>
 
What am I doing wrong?
Posted : 16 February 2012 00:55
I'm not sure I understood well your problem.

For me, it's an expected behaviour that if you enter a text that doesn't match any property value of all your results, then none of the result is displayed.
Posted : 16 February 2012 10:44
Ergo the problem.

For instance, if 50 percent of my entries contain the city "GULFPORT" when I type "GU" EVERYTHING is removed including the entries for GULFPORT, GUATIER, and GULF COAST.
Posted : 16 February 2012 14:47
Any chance you post a sample with mocked data? I need to know how results sent from the server look like
Posted : 20 February 2012 09:56
Did you ever find an answer to this? I've been trying to figure out the same thing.
Posted : 25 September 2012 20:16

5 Item(s)

per page