PDA

View Full Version : [CLOSED] ControlParameter PropertyName for selected value of Combobox



Manni
Oct 08, 2012, 7:15 PM
I have two questions on how to use an object data source together with a combo box:

1. I am trying to use the selected value of a combobox as the control parameter for the select method of a object data source. Which property of the EXT combobox do I use? ('SelectedItem' generates the error "Type 'Ext.Net.ListItem' in Assembly 'Ext.Net, Version=2.1.0.21329, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87' is not marked as serializable. " , 'SelectedValue' as with a standard ASP drop down list does not work.



<asp:ObjectDataSource ID="odsStatus" runat="server" SelectMethod="GetStatus" TypeName="Test.Models.Application" >
<SelectParameters>
<asp:ControlParameter ControlID="cbApplicationStatus" Name="ParentNode" PropertyName="SelectedValue" Type="Int32"
DefaultValue="101"/>
</SelectParameters>
</asp:ObjectDataSource>




2. Do I need to specify DirectEvents to pick up any selection changes and then pass it on to the object data source?


<ext:ComboBox ID="cbApplicationStatus" runat="server" Width="130" Editable="false"
DisplayField="Status" ValueField="Node"
StoreID="storeApplicationStatusChildren" QueryMode="Local">
<DirectEvents>
<Change OnEvent="cbApplicationStatus_Change"></Change>
</DirectEvents>
</ext:ComboBox>



Here is the store:


<ext:Store ID="storeApplicationStatusChildren" runat="server" DataSourceID="odsStatus">
<Model>
<ext:Model ID="modelApplicationStatusChildren" runat="server" IDProperty="Node">
<Fields>
<ext:ModelField Name="Status" Type="String" />
<ext:ModelField Name="ParentNode" Type="Int" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

Any help is greately appricated.
Manni

Manni
Oct 08, 2012, 9:19 PM
After some more research and testing I have come to the conclusion that 'SelectedItem' is the correct PropertyName for the SelectParameters of the object data source. However, using the code below, I get the following error message:

Type 'Ext.Net.ListItem' in Assembly 'Ext.Net, Version=2.1.0.21329, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87' is not marked as serializable.





<ext:ComboBox ID="ComboBox1" runat="server"
QueryMode="Local" StoreID="store1" Editable="false"
DisplayField="Status" ValueField="Node" >
</ext:ComboBox>

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetTest" TypeName="Test.Models.Application">
<SelectParameters>
<asp:ControlParameter ControlID="ComboBox1" DefaultValue="101" Name="ParentNode"
PropertyName="SelectedItem" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>


<ext:Store ID="store1" runat="server" DataSourceID="ObjectDataSource1">
<Model>
<ext:Model ID="model1" runat="server" IDProperty="Node">
<Fields>
<ext:ModelField Name="Status" Type="String" />
<ext:ModelField Name="ParentNode" Type="Int" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

Can someone from the Dev Team or Support reproduce and confirm this behavior?

If not, where is my mistake?

Thanks!

Daniil
Oct 09, 2012, 12:06 PM
Hi @Manni,

Thank you for the question. We will investigate a possibility to get it working.

Daniil
Oct 09, 2012, 7:12 PM
For now we can suggest to use the ObjectDataSource Selecting event to manually manage the required parameter.

Manni
Oct 09, 2012, 10:29 PM
Thanks, Daniil. I got it to work with the Selecting event.

Will this issue be resolved with the next minor release?

Daniil
Oct 10, 2012, 5:56 AM
Will this issue be resolved with the next minor release?

I am not sure yet. We are still investigating.

Manni
Oct 31, 2012, 3:46 PM
I am not sure yet. We are still investigating.

Hi Daniil,
any update on this?
Manni

Daniil
Oct 31, 2012, 6:35 PM
I had another look at the issue and was unable to reproduce.

Here is my test case.

A SelectedItem property is a ListItem type. I think it is wrong to set up int type for the ControlParameter.

Example Page

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Rebind(object sender, DirectEventArgs e)
{
this.Store1.DataBind();
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:ComboBox ID="ComboBox1" runat="server" QueryMode="Local">
<Items>
<ext:ListItem Text="Item 1" Value="1" Mode="Raw" />
<ext:ListItem Text="Item 2" Value="2" Mode="Raw" />
</Items>
<SelectedItems>
<ext:ListItem Text="Item 1" Value="1" Mode="Raw" />
</SelectedItems>
</ext:ComboBox>

<asp:ObjectDataSource
ID="ObjectDataSource1"
runat="server"
TypeName="Test"
SelectMethod="GetTest">
<SelectParameters>
<asp:ControlParameter
ControlID="ComboBox1"
Name="ParentNode"
PropertyName="SelectedItem" />
</SelectParameters>
</asp:ObjectDataSource>


<ext:Store ID="Store1" runat="server" DataSourceID="ObjectDataSource1">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Status" Type="String" />
<ext:ModelField Name="ParentNode" Type="Int" />
</Fields>
</ext:Model>
</Model>
<Listeners>
<Load Handler="App.Container1.update(records[0].data);" />
</Listeners>
</ext:Store>

<ext:Button runat="server" Text="Re-bind" OnDirectClick="Rebind" />

<ext:Container ID="Container1" runat="server">
<Tpl>
<Html>
Status : {Status} <br/>
ParentNode : {ParentNode}
</Html>
</Tpl>
</ext:Container>
</form>
</body>
</html>

Test Class

using Ext.Net;

public class Test
{
public object[] GetTest(ListItem ParentNode)
{
return
new object[]
{
new object[] { ParentNode.Text, int.Parse(ParentNode.Value) }
};
}
}

Manni
Nov 05, 2012, 7:03 PM
Thanks Daniil. I will have to revisit this issue and will let you know.

Daniil
Nov 06, 2012, 6:00 AM
Good. Please feel free to update the thread with any new related info despite it is marked closed.