May 26, 2017, 3:38 PM
[OPEN] [#1487] [4.2.1] GridPanel RowEditing with dynamic data from DirectMethod
Hello, I want to load dynamic data for RowEditing plug-in through DirectMethod.
A GridPanel has 1 column displayed as text, in Editor mode has a ComboBox and every time I edit one row I want load data from server.
The problem is that the row editing mode (the ComboBox) disappear immediately.
Can you help me?
A GridPanel has 1 column displayed as text, in Editor mode has a ComboBox and every time I edit one row I want load data from server.
The problem is that the row editing mode (the ComboBox) disappear immediately.
Can you help me?
<head runat="server">
<title>Row Editing - Dynamic ComboBox</title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
stCustom.DataSource = DataFactory.GetGridItems();
stCustom.DataBind();
}
[DirectMethod(ShowMask = true)]
public void reCustom_BeforeEdit()
{
stName.DataSource = DataFactory.GetComboNameItems();
stName.DataBind();
}
public class DataFactory
{
public static List<GridItem> GetGridItems()
{
return Enumerable.Range(1, 10).ToList().Select(i => new GridItem()
{
Name = "Name_0",
}).ToList();
}
public static List<ComboItem> GetComboNameItems()
{
return Enumerable.Range(1, 5).ToList().Select(i => new ComboItem()
{
Description = "Name_" + i,
Value = i
}).ToList();
}
}
public class GridItem
{
public string Name { get; set; }
}
public class ComboItem
{
public string Description { get; set; }
public int Value { get; set; }
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="grdCustom" runat="server"
Width="800" Title="Row Editing - Dynamic Combo">
<Store>
<ext:Store ID="stCustom" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Plugins>
<ext:RowEditing ID="reCustom" runat="server" ClicksToMoveEditor="1" AutoCancel="false">
<Listeners>
<BeforeEdit Handler="App.direct.reCustom_BeforeEdit();" />
</Listeners>
</ext:RowEditing>
</Plugins>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="Name" DataIndex="Name" Flex="1">
<Editor>
<ext:ComboBox runat="server" ID="cbName"
DisplayField="Description" ValueField="Id"
QueryMode="Local">
<Store>
<ext:Store ID="stName" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="Description" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>