PDA

View Full Version : [CLOSED] ComboBox resetting multiSelect value



cwolcott
May 16, 2014, 1:45 PM
I have a dialog that is reconfigured based on how I am using it. One control is a combobox that I need to switch from MultiSelect to SingleSelect and maybe back again.

I now have to code working but I had to ReRender the control after setting MultiSelect in the behind code. Does that sound correct?

Just wanted to make sure I am not doing something I am not suppose to do and have consequences down the line.

I typically do not use Render or Rerender anywhere in my code. But is there a basic rule that if you change config parameters after the control has been rendered you should rerender it.

Daniil
May 16, 2014, 3:33 PM
Hi Chris,

Yes, it is a basic rule - if you need to change some settings, you might need to re-render a component, unless it is possible to change some setting on the fly. Many options are possible to change on the fly, some ones are not. If you don't know it is possible to change on the fly or not, re-rendering is a way to go or investigation how to change it on the fly:)

It appears to possible to change a selection mode on the fly.

Example

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

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.ComboBox1.GetStore();
store.DataSource = new object[]
{
new object[] { "1", "Item 1" },
new object[] { "2", "Item 2" },
new object[] { "3", "Item 3" }
};
}
}
</script>

<!DOCTYPE html>

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

<ext:Button
runat="server"
Text="Single select"
Handler="App.ComboBox1.multiSelect = false;
App.ComboBox1.getPicker().selModel.setSelectionMod e('SINGLE');
App.ComboBox1.clearValue();"
/>

<ext:Button
runat="server"
Text="Multi select"
Handler="App.ComboBox1.multiSelect = true;
App.ComboBox1.getPicker().selModel.setSelectionMod e('SIMPLE');"
/>

<ext:ComboBox
ID="ComboBox1"
runat="server"
DisplayField="text"
ValueField="value">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="value" />
<ext:ModelField Name="text" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
</ext:ComboBox>
</form>
</body>
</html>