PDA

View Full Version : Remote Combox ObjectDataSource Loading Bug



protactinium
Feb 05, 2010, 8:52 PM
Hi all,

I'm having a trouble with a comboBox.

I have created a comboBox linked to a Store. The Store is linked to an objectDataSource with a remote paging.

The only problem I'm having is that when I load the comboBox with an existing "ChefHierarchiqueId" passed as Value, the comboBox doesn't retrieve the related "matricule" as Text but it show the value "ChefHierarchiqueId" as Text also.


Here you are my code

1- The comboBox is binded to Employee Table. It retrieves the "Matricule" as DisplayField and "EmployeId" as Value.




<ext:Anchor Horizontal="95%" IsFormField="true">
<ext:ComboBox ID="ChefHierarchiqueIdField" runat="server" StoreID="H11EmployeStoreFK"
DisplayField="Matricule" ValueField="EmployeId" FieldLabel="Matricule" TypeAhead="false"
LoadingText="Recherche en cours..." PageSize="20" Mode="Remote" DataIndex="ChefHierarchiqueId"
MinChars="1" ItemSelector="div" FieldClass="fieldSelector">
<Template ID="ChefHierarchiqueIdTemplate" runat="server">
<tpl for=".">
<div style="font-size: 11px ; padding: 3px 10px 3px 10px; border: 1px solid #fff;border-bottom: 1px solid #eeeeee; white-space: normal; color: #555;">
<h3 style="display: block; font: inherit ; font-weight: bold; color: #15428b;">{NomEmploye}, {PrenomEmploye}</h3>
{Matricule}


</tpl>
</Template>
<Triggers>
<ext:FieldTrigger Icon="Clear" Qtip="Cliquer pour vider le champ" HideTrigger="false" />
</Triggers>
<Listeners>
<Render Handler="this.triggers[1].hide();" />
<Select Handler="this.triggers[0].show();" />
<BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
<TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
</Listeners>
</ext:ComboBox>
</ext:Anchor>



2- My DataSource.



<data:H11EmployeDataSource ID="H11EmployeDataSourceFK" runat="server" SelectMethod="GetPaged"
EnableDeepLoad="false" EnableSorting="true" OnSelected="H11EmployeDataSourceFK_Selected">
<DeepLoadProperties Method="IncludeChildren" Recursive="False">
</DeepLoadProperties>
<Parameters>
<data:SqlParameter Name="WhereClause" UseParameterizedFilters="false" ConvertEmptyStringToNull="false">
<Filters>
<data:H11EmployeFilter Column="Matricule" ComparisionType="Contains" ControlID="ChefHierarchiqueIdFieldFilter"
PropertyName="Text" />
<data:H11EmployeFilter Column="EmployeId" ComparisionType="Contains" ControlID="ChefHierarchiqueIdFieldFilterId"
PropertyName="Text" />
</Filters>
</data:SqlParameter>
<asp:ControlParameter Name="PageIndex" ControlID="TextBoxIndex" PropertyName="Text"
Type="Int32" />
<asp:ControlParameter Name="PageSize" ControlID="TextBoxSize" PropertyName="Text"
Type="Int32" />
<data:CustomParameter Name="RecordCount" Value="0" Type="Int32" Direction="Output" />
</Parameters>
</data:H11EmployeDataSource>
<ext:Store runat="server" ID="H11EmployeStoreFK" DataSourceID="H11EmployeDataSourceFK"
IgnoreExtraFields="true" AutoLoad="True" OnRefreshData="H11EmployeStoreFK_RefreshData">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="EmployeId" />
<ext:RecordField Name="Matricule" />
<ext:RecordField Name="NomEmploye" />
<ext:RecordField Name="PrenomEmploye" />
<ext:RecordField Name="SexeEmploye" />
<ext:RecordField Name="AdressesEmail" />
</Fields>
</ext:JsonReader>
</Reader>
<AutoLoadParams>
<ext:Parameter Name="start" Value="0" Mode="Raw" />
<ext:Parameter Name="limit" Value="20" Mode="Raw" />
</AutoLoadParams>
<Proxy>
<ext:DataSourceProxy />
</Proxy>
<Listeners>
<%-- <BeforeLoad Handler="#{GridPanelEmploye}.body.mask('Loading...', 'x-mask-loading');" />
<Load Handler="#{GridPanelEmploye}.body.unmask();" />
<LoadException Handler="#{GridPanelEmploye}.body.unmask();" />--%>
</Listeners>
</ext:Store>
<asp:TextBox ID="TextBoxParams" runat="server" Visible="false"></asp:TextBox>
<asp:TextBox ID="TextBoxIndex" runat="server" Visible="false" Text="1"></asp:TextBox>
<asp:TextBox ID="TextBoxSize" runat="server" Visible="false" Text="20"></asp:TextBox>
<asp:TextBox ID="ChefHierarchiqueIdFieldFilter" runat="server" Visible="false"></asp:TextBox>
<asp:TextBox ID="ChefHierarchiqueIdFieldFilterId" runat="server" Visible="false"></asp:TextBox>


3- Codebehind code :



protected void H11EmployeDataSourceFK_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
(this.H11EmployeStoreFK.Proxy[0] as DataSourceProxy).TotalCount = e.AffectedRows;
}

protected void H11EmployeStoreFK_RefreshData(object sender, StoreRefreshDataEventArgs e)
{
//this.ProductsDataSource1.Parameters["PageIndex"].DefaultValue = e.Start.ToString();
//ProductsDataSource1.Parameters["PageSize"].DefaultValue = e.Limit.ToString();
int pageSize = int.Parse(this.TextBoxSize.Text);
this.TextBoxIndex.Text = (e.Start / pageSize).ToString();
this.H11EmployeDataSourceFK.Parameters["PageIndex"].DefaultValue = this.TextBoxIndex.Text;
this.H11EmployeDataSourceFK.Parameters["PageSize"].DefaultValue = pageSize.ToString();
if (this.ChefHierarchiqueIdField.SelectedItem.Text != string.Empty)
this.ChefHierarchiqueIdFieldFilter.Text = this.ChefHierarchiqueIdField.SelectedItem.Text;
else if (this.ChefHierarchiqueIdField.SelectedItem.Value != string.Empty)
this.ChefHierarchiqueIdFieldFilterId.Text = e.pa;
H11EmployeStoreFK.DataBind();
}



Looking forward for your help

protactinium
Feb 08, 2010, 11:09 AM
Hey,

I have found my problem but without getting the solution.

I have a remote paged dataStore.

So, when I bind my ComboBox to an Item that doesn't exist in the current page, the combobox doesn't load the right related item(it shows as text the value).

Then, I tried to get the value of the combobox but the this.ChefHierarchiqueIdField.SelectedItem.Value is empty.

Can you help me since it's getting me crazy :))

Thanks a lot for you help.

protactinium
Feb 08, 2010, 7:25 PM
Hey,


I tried to figure out how to pass parameters to the H11EmployeStoreFK_RefreshData containing the Value of the combobox when loading




<BaseParams>
<ext:Parameter Name="sectorId" Value="#{ChefHierarchiqueIdField}.getValue()" Mode="Raw" />
</BaseParams>



But it still not working.


So, I changed the Autoload of the Store "H11EmployeStoreFK" to false and added to the render Listener of the combobox "ChefHierarchiqueIdField" like shown below.


I was able to retrieve the ValueId with the correct value but I was not able to show the data into the ComboBox (the combobox shows the Value as Text). I think that the combobox is rendering itself before the StoreLoad data.





<ext:Anchor Horizontal="95%" IsFormField="true">


<ext:ComboBox ID="ChefHierarchiqueIdField" runat="server" StoreID="H11EmployeStoreFK"


DisplayField="Matricule" ValueField="EmployeId" FieldLabel="Matricule" LoadingText="Recherche en cours..."


PageSize="20" Mode="Remote" DataIndex="ChefHierarchiqueId" MinChars="1" ItemSelector="div"


FieldClass="fieldSelector">


<Template ID="ChefHierarchiqueIdTemplate" runat="server">


<tpl for=".">


<div style="font-size: 11px ; padding: 3px 10px 3px 10px; border: 1px solid #fff;border-bottom: 1px solid #eeeeee; white-space: normal; color: #555;">


<h3 style="display: block; font: inherit ; font-weight: bold; color: #15428b;">{NomEmploye}, {PrenomEmploye}</h3>


{Matricule}






</tpl>


</Template>


<Triggers>


<ext:FieldTrigger Icon="Clear" Qtip="Cliquer pour vider le champ" HideTrigger="false" />


</Triggers>


<Listeners>


<Render Handler="this.triggers[1].hide(); this.triggers[0].hide(); #{H11EmployeStoreFK}.reload();" />


<Select Handler="this.triggers[0].show();" />


<BeforeQuery Handler="this.triggers[0][ this.getValue().toString().length == 0 ? 'hide' : 'show'](); #{H11EmployeStoreFK}.reload();" />


<TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />


</Listeners>


</ext:ComboBox>


Any help ?