PDA

View Full Version : [CLOSED] how to set Column 's id and text from dropdownlist



hdsoso
May 20, 2013, 10:08 AM
<ext:Column ID="col_kjkm" runat="server" Text="会计科目" Flex="1" DataIndex="Ccode">
<Editor>
<ext:DropDownField runat="server">
<Component>
<ext:TreePanel runat="server" ID="tp_subject" MaxHeight="200" Shadow="false" UseArrows="true" AutoScroll="true" Animate="true" RootVisible="false">
<Store>
<ext:TreeStore runat="server">

<Proxy>
<ext:AjaxProxy Url="~/BasicInfoAshx/SubjectTree.ashx">
</ext:AjaxProxy>
</Proxy>
</ext:TreeStore>
</Store>
<DirectEvents>
<ItemDblClick OnEvent="NodeDbClick">
<ExtraParams>
<ext:Parameter runat="server" Name="id" Value="record.data.id" Mode="Raw" />
<ext:Parameter runat="server" Name="text" Value="record.data.text" Mode="Raw" />
</ExtraParams>
</ItemDblClick>
</DirectEvents>
</ext:TreePanel>
</Component>
</ext:DropDownField>
</Editor>
</ext:Column>



protected void NodeDbClick(object sender, DirectEventArgs e)
{
string id = e.ExtraParams["id"];
string text = e.ExtraParams["text"];

}

i get id and text from treepanel, but how to set id and text to the column col_kjkm?

Daniil
May 20, 2013, 11:28 AM
Hi @hdsoso,

If you need to use a value/text pair you should use Mode="ValueText".
http://examples2.ext.net/#/Form/DropDownField/ValueText_Mode/

Also I think instead of an ItemDblClick DirectEvent, you use an ItemDblClick listener and call a DropDownField's setValue method in a similar way as it is done within the CheckChange listener of the example mentioned above.

hdsoso
May 21, 2013, 8:23 AM
can't hold on the text value in the cell which column id is "col_kjkm" when click other cell after double click the tree item.
plz see http://screencast.com/t/qs8GWdsUB

my code


<ext:GridPanel runat="server" ID="gp_pingzheng">

<Store>
<ext:Store runat="server" ID="store_pz">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField runat="server" Name="Digest"></ext:ModelField>
<ext:ModelField runat="server" Name="Ccode"></ext:ModelField>
<ext:ModelField runat="server" Name="Jfsl"></ext:ModelField>
<ext:ModelField runat="server" Name="Dfsl"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:SummaryColumn ID="Column1" runat="server" Text="摘要" Flex="2" DataIndex="Digest">
<SummaryRenderer Handler="return '合计:'"></SummaryRenderer>
<Editor>
<ext:TextField ID="TextField1" runat="server"></ext:TextField>
</Editor>
</ext:SummaryColumn>
<ext:Column ID="col_kjkm" runat="server" Text="会计科目" Flex="1" DataIndex="Ccode">
<Editor>
<ext:DropDownField ID="ddf_kemu" runat="server" Mode="ValueText">
<Component>
<ext:TreePanel runat="server" ID="tp_subject" MaxHeight="400" Shadow="false" UseArrows="true" AutoScroll="true" Animate="true" RootVisible="false">
<View>
<ext:TreeView ID="TreeView1" runat="server" LoadMask="true" />
</View>
<Store>
<ext:TreeStore runat="server">

<Proxy>
<ext:AjaxProxy Url="~/BasicInfoAshx/SubjectTree.ashx">
</ext:AjaxProxy>
</Proxy>
</ext:TreeStore>
</Store>
<DirectEvents>
<ItemDblClick OnEvent="NodeDbClick">
<ExtraParams>
<ext:Parameter runat="server" Name="id" Value="record.data.id" Mode="Raw" />
<ext:Parameter runat="server" Name="text" Value="record.data.text" Mode="Raw" />
<ext:Parameter runat="server" Name="leaf" Value="record.data.leaf" Mode="Raw" />
</ExtraParams>
</ItemDblClick>
</DirectEvents>
</ext:TreePanel>
</Component>
</ext:DropDownField>
</Editor>
</ext:Column>
<ext:SummaryColumn SummaryType="Sum" ID="NumberColumn1" runat="server" Flex="1" Text="借方金额" DataIndex="Jfsl">
<Renderer Handler="if(value!=null)return value +'元';" />
<SummaryRenderer Handler="if(value!=0)return value +'元';" />
<Editor>
<ext:NumberField ID="NumberField3" runat="server"></ext:NumberField>
</Editor>
</ext:SummaryColumn>
<ext:SummaryColumn SummaryType="Sum" ID="NumberColumn2" runat="server" Flex="1" Text="贷方金额" DataIndex="Dfsl">
<Renderer Handler="if(value!=null)return value +'元';" />
<SummaryRenderer Handler="if(value!=0)return value +'元';" />
<Editor>
<ext:NumberField ID="NumberField4" runat="server"></ext:NumberField>
</Editor>
</ext:SummaryColumn>
</Columns>
</ColumnModel>
<Features>
<ext:Summary ID="Summary1" runat="server" />
</Features>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server">
<Listeners>
<Edit Fn="edit" />
</Listeners>
</ext:CellEditing>
</Plugins>

</ext:GridPanel>

Daniil
May 21, 2013, 10:46 AM
You should defined a Renderer for the Column.

Please see the Department column here.
http://examples2.ext.net/#/GridPanel/Data_Presentation/Editor_Field_Mapping/

There is a ComboBox as an Editor, but it is exactly your scenario.