PDA

View Full Version : [CLOSED] ComponentColumn does not auto selected according datasource



hdsoso
Oct 22, 2013, 3:00 PM
i follow the example http://examples2.ext.net/#/GridPanel/ComponentColumn/Editor/
but my combobox does not auto selected according datasource
7089
below is my code


<script>
var nodeLoad = function (store, operation, options) {
var node = operation.node;

App.direct.NodeLoad(node.getId(), {
success: function (result) {
node.set('loading', false);
node.set('loaded', true);
var data = Ext.decode(result);
node.appendChild(data, undefined, true);
node.expand();
},

failure: function (errorMsg) {
Ext.Msg.alert('Failure', errorMsg);
}
});

return false;
};
</script>



[DirectMethod]
public string NodeLoad(int? nodeID)
{
var nodes = new Ext.Net.NodeCollection();
var ll = navService.ChildNavByPid(nodeID);
foreach (var column1 in ll)
{
Node n = new Node();
n.Text = column1.nav;
n.CustomAttributes.Add(new ConfigItem("id", column1.id.ToString()));
n.CustomAttributes.Add(new ConfigItem("nav", column1.nav));
n.CustomAttributes.Add(new ConfigItem("url", column1.url));
n.CustomAttributes.Add(new ConfigItem("pid", nodeID.ToString()));
n.CustomAttributes.Add(new ConfigItem("ord", column1.ord.ToString()));
n.CustomAttributes.Add(new ConfigItem("target", nodeID.ToString()));
n.NodeID = column1.id.ToString();
var _ll = navService.ChildNavByPid(column1.id);
if (_ll.Count <= 0) n.Leaf = true;
else n.Expanded = true;
nodes.Add(n);
}
// string s = @"[{'id':'1','leaf':true,'text':'首页','id':1,'nav':'首页 ','url':'index.aspx','pid':0,'ord':1,'target':0},{ 'id':'6','leaf':true,'text':'更新日志','id':6,'nav':'更 新日志','url':'col.aspx?cid=25','pid':0,'ord':3,'targ et':0},{'id':'2','leaf':true,'text':'关于我们','id':2, 'nav':'关于我们','url':'company1.aspx','pid':0,'ord':4 ,'target':0},{'id':'7','expanded':true,'text':'新闻' ,'id':7,'nav':'新闻','url':'#','pid':0,'ord':99,'tar get':0},{'id':'8','leaf':true,'text':'论坛','id':8,' nav':'论坛','url':'http://www.hdsoso.com','pid':0,'ord':1300,'target':0}]";
return nodes.ToJson();
// return s;
}



<ext:TreePanel
ID="TreePanel1"
runat="server"
Title="导航管理"
ColumnLines="True">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button3" runat="server" Text="新增" Icon="ApplicationFormAdd">
<Listeners>
<Click Handler="#{w_addcol}.show();"></Click>
</Listeners>
</ext:Button>
<ext:Button ID="Button4" runat="server" Text="删除" Icon="Delete">
<Listeners>
<Click Fn="rm_selected_node" />
</Listeners>
</ext:Button>
<ext:Button ID="Button5" runat="server" Text="确定" Icon="Disk">
<DirectEvents>
<Click OnEvent="BatchUpdate">
<ExtraParams>
<ext:Parameter Name="data" Value="App.TreePanel1.store.getChangedData()" Mode="Raw" Encode="true" />
</ExtraParams>
<EventMask ShowMask="True"></EventMask>
<Confirmation Title="提示" ConfirmRequest="True" BeforeConfirm="this.message = '确实要这样做吗?';"></Confirmation>
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="bt_fresh" runat="server" Text="刷新" Icon="PageRefresh">
<Listeners>
<Click Handler="window.location='nav.aspx';"></Click>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Root>
<ext:Node NodeID="0" Text="根节点">
<CustomAttributes>
<ext:ConfigItem Name="id" Value="0" />
<ext:ConfigItem Name="nav" Value="根栏目" />
<ext:ConfigItem Name="pid" Value="-1" />
<ext:ConfigItem Name="target" Value="0" />
</CustomAttributes>
</ext:Node>
</Root>
<Listeners>
<BeforeLoad Fn="nodeLoad" />
</Listeners>
<Store>
<ext:TreeStore runat="server" ID="s_column">
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="id"></ext:ModelField>
<ext:ModelField Name="nav"></ext:ModelField>
<ext:ModelField Name="url"></ext:ModelField>
<ext:ModelField Name="pid"></ext:ModelField>
<ext:ModelField Name="ord"></ext:ModelField>
<ext:ModelField Name="target" Type="Int"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:TreeStore>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" DataIndex="id" Text="编号"></ext:Column>
<ext:TreeColumn ID="TreeColumn2" runat="server" DataIndex="nav" Text="导航" Flex="1">
<Editor>
<ext:TextField ID="TextField1" runat="server"></ext:TextField>
</Editor>
</ext:TreeColumn>
<ext:Column runat="server" DataIndex="url" Text="url" Flex="1"></ext:Column>
<ext:Column runat="server" DataIndex="ord" Text="顺序">
<Editor>
<ext:NumberField runat="server"></ext:NumberField>
</Editor>
</ext:Column>
<ext:ComponentColumn runat="server" DataIndex="target" Text="打开方式" Border="False">
<Component>
<ext:ComboBox ID="cb_target" runat="server">
<Items>
<ext:ListItem Value="0" Text="当前页面" Mode="Raw" />
<ext:ListItem Value="1" Text="新页面" Mode="Raw" />
</Items>

</ext:ComboBox>
</Component>

</ext:ComponentColumn>

<ext:Column ID="Column2" runat="server" DataIndex="pid" Text="父id">
<Editor>
<ext:NumberField ID="NumberField1" runat="server"></ext:NumberField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing ID="CellEditing1" ClicksToEdit="1" runat="server"></ext:CellEditing>
</Plugins>
<SelectionModel>
<ext:TreeSelectionModel ID="TreeSelectionModel1" runat="server" Mode="Multi" />
</SelectionModel>
</ext:TreePanel>


please check what i am missing?

Daniil
Oct 22, 2013, 5:13 PM
Hi @hdsoso,

Please try to replace

Mode="Raw"
with

Mode="Value"
for the ComboBox's ListItems.

hdsoso
Oct 22, 2013, 11:23 PM
Hi @hdsoso,

Please try to replace

Mode="Raw"
with

Mode="Value"
for the ComboBox's ListItems.

does not work.

Baidaly
Oct 23, 2013, 12:17 AM
Hello!

You should mark the Component as an editor:


<ext:ComponentColumn runat="server" DataIndex="target" Text="打开方式" Border="False" Editor="True">


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

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

<!DOCTYPE html>

<html>
<head runat="server">
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" ScriptMode="Debug" SourceFormatting="True" />
<ext:TreePanel
runat="server"
Width="500"
Height="300"
Collapsible="true"
UseArrows="true"
RootVisible="false"
MultiSelect="true"
SingleExpand="true"
FolderSort="true">
<Fields>
<ext:ModelField Name="task" />
<ext:ModelField Name="user" />
<ext:ModelField Name="duration" />
<ext:ModelField Name="done" Type="Boolean" />
<ext:ModelField Name="target" Type="Int" />
</Fields>
<ColumnModel>
<Columns>
<ext:TreeColumn
runat="server"
Text="Task"
Flex="2"
Sortable="true"
DataIndex="task" />
<ext:Column
runat="server"
Text="Assigned To"
Flex="1"
Sortable="true"
DataIndex="user">
</ext:Column>

<ext:ComponentColumn
runat="server"
Text="Target"
Flex="1"
Sortable="true"
Editor="True"
DataIndex="target">
<Component>
<ext:ComboBox runat="server">
<Items>
<ext:ListItem Value="1" Text="当前页面" Mode="Raw" />
<ext:ListItem Value="2" Text="新页面" Mode="Raw" />
</Items>
<Listeners></Listeners>
</ext:ComboBox>
</Component>
</ext:ComponentColumn>
</Columns>

</ColumnModel>

<Root>
<ext:Node Text="Tasks">
<Children>
<ext:Node Icon="Folder" Expanded="true">
<CustomAttributes>
<ext:ConfigItem Name="task" Value="Project: Shopping" Mode="Value" />
<ext:ConfigItem Name="duration" Value="13.25" />
<ext:ConfigItem Name="user" Value="Tommy Maintz" Mode="Value" />
<ext:ConfigItem Name="target" Value="1" Mode="Raw" />
</CustomAttributes>
<Children>
<ext:Node Icon="Folder">
<CustomAttributes>
<ext:ConfigItem Name="task" Value="Housewares" Mode="Value" />
<ext:ConfigItem Name="duration" Value="1.25" />
<ext:ConfigItem Name="user" Value="Tommy Maintz" Mode="Value" />
<ext:ConfigItem Name="target" Value="2" Mode="Raw" />
</CustomAttributes>
<Children>
<ext:Node Leaf="true">
<CustomAttributes>
<ext:ConfigItem Name="task" Value="Kitchen supplies" Mode="Value" />
<ext:ConfigItem Name="duration" Value="0.25" />
<ext:ConfigItem Name="user" Value="Tommy Maintz" Mode="Value" />
<ext:ConfigItem Name="target" Value="1" Mode="Raw" />
</CustomAttributes>
</ext:Node>
<ext:Node Leaf="true">
<CustomAttributes>
<ext:ConfigItem Name="task" Value="Groceries" Mode="Value" />
<ext:ConfigItem Name="duration" Value="0.4" />
<ext:ConfigItem Name="user" Value="Tommy Maintz" Mode="Value" />
<ext:ConfigItem Name="done" Value="true" Mode="Raw" />
<ext:ConfigItem Name="target" Value="1" Mode="Raw" />
</CustomAttributes>
</ext:Node>
</Children>
</ext:Node>
</Children>
</ext:Node>
</Children>
</ext:Node>
</Root>
</ext:TreePanel>
</form>
</body>
</html>

hdsoso
Oct 23, 2013, 12:43 AM
thank you very much , resolved.