PDA

View Full Version : [CLOSED] Combobox with autoload migration from 1.0 to 2.0



blueworld
Oct 09, 2012, 12:35 PM
Hello,

I have a 1.0 implementation of a ComboBox that uses an autoload-store

store:


<ext:Store ID="ReportNameStore" runat="server" AutoLoad="true">
<Proxy>
<ext:PageProxy />
</Proxy>
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>


Combobox:



<ext:ComboBox ID="ReportName" runat="server" Editable="true" TypeAhead="true" QueryMode="Local"
StoreID="ReportNameStore" TriggerAction="All" SelectOnFocus="true" DisplayField="Name"
AllowBlank="true" ValueField="Name" EmptyText="Bericht" AnchorHorizontal="100%"
FieldLabel="Bericht">
<Triggers>
<ext:FieldTrigger Icon="Clear" HideTrigger="true" />
</Triggers>
<Listeners>
<Select Handler="this.getTrigger[0].show();" />
<BeforeQuery Handler="this.getTrigger[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
<TriggerClick Handler="if (index == 0) { this.clearValue(); this.getTrigger[0].hide(); }" />
</Listeners>


Serverside signature:




Protected Sub ReportNameStore_RefreshData(ByVal sender As Object, ByVal e As Ext.Net.StoreReadDataEventArgs) Handles ReportNameStore.ReadData

* Query * ....
Dim store As Store = sender
store.DataSource = queryResult
store.DataBind()
End Sub




Well, this combobox does not get filled, and if I try to open the combobox the browser debugger tells me
Uncaught TypeError: Cannot call method 'hide' of undefined

Daniil
Oct 09, 2012, 12:47 PM
Hi @blueworld,



Well, this combobox does not get filled, and if I try to open the combobox the browser debugger tells me

Please use

getTrigger(0)
instead of

getTrigger[0]

I.e. round brackets instead of square ones.

As it is in this example.
http://examples2.ext.net/#/Form/ComboBox/TriggerButtons/

I think the ComboBox should be populated well. Sure, if the "queryResult" is correct.

By the way, AutoLoad is true by default.

blueworld
Oct 09, 2012, 1:00 PM
Hi Daniiil,

thank you, this fixed the javascript exception but the combobox is still empty. QueryResult delievers 5 objects and the readdata function gets executed if I reload the page so this cant be the problem.

The response after the page has loaded is:
{serviceResponse:{success:true,data:{data:[], total: 0}}}

Daniil
Oct 09, 2012, 1:30 PM
What is the queryResult?

blueworld
Oct 09, 2012, 1:45 PM
What is the queryResult?




Private Class SingleName
Private _name As String

Public Sub New(ByVal name As String)
_name = name
End Sub

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
End Class






Protected Sub ReportNameStore_RefreshData(ByVal sender As Object, ByVal e As Ext.Net.StoreReadDataEventArgs) Handles ReportNameStore.ReadData

Dim reportNames As ArrayList = **NhibernateQuery**

Dim l As New Generic.List(Of SingleName)
For Each s As String In reportNames
l.Add(New SingleName(s))
Next

Dim store As Store = sender
Me.ReportNameStore.DataSource = l
Me.ReportNameStore.DataBind()
End Sub




Is PageProxy correct inside the store? In 1.0 the handler has been OnRefreshData, I have changed this to ReadData, is this correct?

Daniil
Oct 09, 2012, 2:42 PM
Is PageProxy correct inside the store? In 1.0 the handler has been OnRefreshData, I have changed this to ReadData, is this correct?

Yes, the both statements are correct.

I checked your code removing this

Dim reportNames As ArrayList = **NhibernateQuery**
and populating the ArrayList with just Guids. It appears to be working well.

Please double ensure an object that you apply for DataSource is a collection of objects with the Name property (according the Store Model).

If the issue persists, please provide a full test case that we could run without any changes from our side.

By the way, do you use the latest sources for SVN?

blueworld
Oct 09, 2012, 3:25 PM
Hi Daniil,

I have just updated to 2.1 and it is working now. Thank you. This can be closed.