PDA

View Full Version : [CLOSED] why text disapear when click the dropdown column



hdsoso
Aug 04, 2013, 1:13 PM
when click the downdown column which id is "col_menu", when the column cell text disapear. why?


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="role_menu.aspx.cs" Inherits="extdemo.admin.pages.role_menu" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script>
var roleRenderer = function (value) {
if (!Ext.isEmpty(value)) {
return App.store_role1.getById(value).data.rolename;
}
return value;
};
var menuRenderer = function (value) {
if (value != null && value != '') {
var r = App.store_menu.getNodeById(value);
if (!Ext.isEmpty(r)) {
return r.data.name;
}
}
};

var fn1 = function (value) {
this.field.onTriggerClick();
App.btn_save.setDisabled(false);
};
var fn2 = function (value) {
this.field.onTriggerClick();
App.btn_save.setDisabled(false);
};
var menu_sel = function (item, record, node, index, e) {

App.ddf_menu.select(record.data.name, record.data.id);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>

<ext:GridPanel runat="server" ID="gp_role" Title="角色菜单管理11">
<Listeners>
<BeforeRender Handler="this.getBinComponent('store_menu').load();" />
</Listeners>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btn_add" runat="server" Icon="Add" Text="新增">
<Listeners>
<Click Handler="App.store_role.insert(0,{rolename:'新角色'});App.btn_ save.enable();"></Click>
</Listeners>
</ext:Button>
<ext:Button runat="server" Text="删除" Icon="Delete" ID="btn_del">
<Listeners>
<Click Handler="var selection = #{RowSelectionModel}.getSelection();
if (selection) {
#{gp_role}.store.remove(selection);
};App.btn_save.enable();" />
</Listeners>
</ext:Button>
<ext:Button ID="btn_save" runat="server" Icon="Disk" Text="确定" Disabled="True">
<DirectEvents>
<Click OnEvent="e_save" Before="return #{store_role}.isDirty();">
<ExtraParams>
<ext:Parameter Name="data" Value="#{store_role}.getChangedData()" Mode="Raw" Encode="true" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>

</Items>
</ext:Toolbar>
</TopBar>
<Store>
<ext:Store runat="server" ID="store_role" AutoLoad="false">
<Proxy>
<ext:AjaxProxy Url="~/admin/pages/role_menu_handler.ashx">
<ActionMethods Read="GET"></ActionMethods>
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="id">
<Fields>
<ext:ModelField runat="server" Name="id">
</ext:ModelField>
<ext:ModelField runat="server" Name="roleid"></ext:ModelField>
<ext:ModelField runat="server" Name="menuid"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Bin>
<ext:TreeStore runat="server" ID="store_menu">
<Listeners>
<Load Handler="App.store_role.load();" />
</Listeners>
<Proxy>
<ext:AjaxProxy Url="../handlers/Handler_menu1.ashx">
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model3" runat="server" IDProperty="id">
<Fields>
<ext:ModelField runat="server" Name="id"></ext:ModelField>
<ext:ModelField runat="server" Name="name"></ext:ModelField>

</Fields>
</ext:Model>
</Model>
</ext:TreeStore>
</Bin>


<ColumnModel>
<Columns>
<ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" />
<ext:Column ID="Column1" runat="server" DataIndex="id" Text="编号"></ext:Column>
<ext:Column ID="Column2" runat="server" Text="角色" DataIndex="roleid" Flex="1">
<Renderer Fn="roleRenderer" />

<Editor>
<ext:SelectBox runat="server" ID="cb_role" DisplayField="rolename" ValueField="id">
<Store>
<ext:Store runat="server" ID="store_role1">
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField runat="server" Name="id"></ext:ModelField>
<ext:ModelField runat="server" Name="rolename"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:SelectBox>
</Editor>
<EditorOptions>
<Listeners>
<StartEdit Fn="fn1" Delay="1" />
</Listeners>
</EditorOptions>
</ext:Column>
<ext:Column ID="col_menu" runat="server" DataIndex="menuid" Flex="1" Text="菜单">
<Renderer Fn="menuRenderer"></Renderer>
<Editor>
<ext:DropDownField runat="server" Editable="False" ID="ddf_menu" Mode="ValueText" TriggerIcon="SimpleArrowDown">
<Component>
<ext:TreePanel ID="TreePanel1" runat="server" RootVisible="false" Animate="true" AutoScroll="true" StoreID="store_menu">

<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" runat="server" Text="名称" DataIndex="name" Flex="1">
</ext:TreeColumn>
</Columns>
</ColumnModel>
<DirectEvents>
<ItemDblClick OnEvent="NodeDbClick">
<ExtraParams>
<ext:Parameter runat="server" Name="id" Value="record.data.id" Mode="Raw" />
<ext:Parameter runat="server" Name="name" Value="record.data.name" Mode="Raw" />
<ext:Parameter runat="server" Name="leaf" Value="record.data.leaf" Mode="Raw" />
</ExtraParams>
</ItemDblClick>
</DirectEvents>
</ext:TreePanel>

</Component>
</ext:DropDownField>


</Editor>
<EditorOptions>
<Listeners>
<StartEdit Fn="fn2" Delay="1" />
</Listeners>
</EditorOptions>
</ext:Column>

</Columns>
</ColumnModel>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server">
</ext:PagingToolbar>
</BottomBar>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server" ClicksToEdit="1" />
</Plugins>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel" Mode="Multi" runat="server" />
</SelectionModel>

</ext:GridPanel>
</form>
</body>
</html>

hdsoso
Aug 04, 2013, 1:19 PM
please see
http://screencast.com/t/6rxcMCeAo7d

hdsoso
Aug 04, 2013, 9:28 PM
using Ext.Net;
using Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using model.crm.hdsoso.com;

namespace extdemo.admin.pages
{
public partial class role_menu : System.Web.UI.Page
{
RoleService _roleService = new RoleService();
RoleMenuService roleMenuService = new RoleMenuService();
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
store_role1.DataSource = _roleService.GetAllRole();
store_role1.DataBind();

}
}

protected void e_save(object sender, DirectEventArgs e)
{

string data = e.ExtraParams["data"];
ChangeRecords<rolemenu> rolemenus = new StoreDataHandler(e.ExtraParams["data"]).BatchObjectData<rolemenu>();
for (int i = rolemenus.Created.Count - 1; i >= 0; i--)
{
var role1 = new rolemenu();
role1.roleid = rolemenus.Created[i].roleid;
role1.menuid = rolemenus.Created[i].menuid;
roleMenuService.Add(role1);
}
foreach (rolemenu deleted in rolemenus.Deleted)
{
roleMenuService.Delete(deleted);
}
foreach (rolemenu updated in rolemenus.Updated)
{
roleMenuService.Update(updated);
}
store_role.Reload();
btn_save.Disable();
}
protected void NodeDbClick(object sender, DirectEventArgs e)
{
string id = e.ExtraParams["id"];
string text = e.ExtraParams["name"];
string leaf = e.ExtraParams["leaf"];
if (leaf == "true")
{
ddf_menu.SetValue(id, text);
}
}
}
}

Daniil
Aug 05, 2013, 7:02 AM
Hi @hdsoso,

Unfortunately, I cannot run the test case.

I guess the following happens. Then you click the column and a DropDownField appears, the column's value is being applied to a DropDownField. I.e. a setValue call is being made. So, if a DropDownField becomes blank, it means that there is no such a value.