PDA

View Full Version : [CLOSED] Display ComboBox in GridPanel depending on value in other column



HansWapenaar
Dec 14, 2012, 12:55 PM
Hi,

Not long ago I got a GridPanel working in such a way that a button in a column (CommandColumn) is only shown when a contents in another column is of a certain value.
I now want to do the same with a ComboBox in the GridPanel.
For the Button I used a PrepareToolbar in the CommandColumn.

In tried to implement a ComboBox in a ComponentColumn, but there not something like a PrepareToolbar.
First question: how to get the combobox hidden for records meeting a certain value.
Second question: is it also possible to fill the contents of a combobox with items depending on the value of another column? Or is it easier to make two comboboxes in the same column and display/hide these depending on the value?

Thanks,
Hans




<script type="text/javascript">
var prepareToolbar = function (grid, toolbar, rowIndex, record) {
if (record.get("datatypeid") !== 4) {
//hide edit button
toolbar.items.getAt(0).hide();
}
};
</script>


<ext:CommandColumn ID="CommandColumn2" runat="server" Text="test" Width="55" MaxWidth="55" >
<Commands>
<ext:GridCommand icon="ApplicationViewTile" CommandName="themeconstruction" >
<ToolTip Text="Thema" />
</ext:GridCommand >
</Commands>
<PrepareToolbar Fn="prepareToolbar" />
<DirectEvents>
<Command OnEvent="Command_Handler">
<ExtraParams >
<ext:Parameter Name="command" Value="command" Mode="Raw" />
<ext:Parameter Name="datatypeid" Value=" record.data.datatypeid" Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>


For the ComboBox:



<script runat="server">
If (Not Page.IsPostBack) Then
If (Not ExtX.IsAjaxRequest) Then
ComboBoxTheme.Items.Clear()
ComboBoxTheme.Items.Add(New Ext.Net.ListItem("item0", "0"))
ComboBoxTheme.Items.Add(New Ext.Net.ListItem("item1", "1"))
ComboBoxTheme.Items.Add(New Ext.Net.ListItem("item2", "2"))
ComboBoxTheme.Items.Add(New Ext.Net.ListItem("item3", "3"))
End If
End If
</script>


<ext:ComponentColumn ID="ComponentColumn1"
runat="server"
Editor="true"
DataIndex="datathemeid"
Flex="1"
Text="Theme" MinWidth="150">
<Component>
<ext:ComboBox ID="ComboBoxTheme" runat="server" Editable="false" EnableKeyEvents="false" >
</ext:ComboBox>
</Component>
</ext:ComponentColumn>

Daniil
Dec 14, 2012, 5:16 PM
Hi Hans,

Please use the ComponentColumn's Bind event. Returning false from a Bind listener will hide a ComboBox.

Also there are the "cmp" (it will a ComboBox instance) and "record"" arguments. You should be able to load required data using these arguments.