Mar 01, 2014, 2:07 PM
[OPEN] [#445] JavaScript error when I try to reconfigure grid with ImageCommandColumn
Hello,
I have some static command columns in the grid and want to add some extra columns.
First I tried to add command column with directevents, but it doesn't work. I have error - control with this id doesn't exist. But If I don't use master page it works good. There are any ideas how it should works?
Next I tried to add direct method, but it works partially. If I have all Handler code in one line it works good
I have some static command columns in the grid and want to add some extra columns.
First I tried to add command column with directevents, but it doesn't work. I have error - control with this id doesn't exist. But If I don't use master page it works good. There are any ideas how it should works?
Next I tried to add direct method, but it works partially. If I have all Handler code in one line it works good
<Command Handler="#{DirectMethods}.DmCommand({eventMask: { showMask: true }});" />
But when I move code to the other line, it doesn't work<Command Handler="
#{DirectMethods}.DmCommand({
eventMask: { showMask: true }
});" />
Same behavior with PrepareCommand.<%@ Master Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" DisableViewState="false">
</ext:ResourceManager>
<form id="form1" runat="server">
<ext:Viewport runat="server">
<Content>
<asp:ContentPlaceHolder ID="BodyContent" runat="server">
</asp:ContentPlaceHolder>
</Content>
</ext:Viewport>
</form>
</body>
</html>
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" %>
<%@ Import Namespace="System.Collections.Generic"%>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
private void AddField(ModelField field)
{
if (X.IsAjaxRequest)
{
this.Store1.AddField(field);
}
else
{
this.Store1.Model[0].Fields.Add(field);
}
}
private void Reconfigure()
{
List<ModelField> fields = new List<ModelField>();
List<ColumnBase> columns = new List<ColumnBase>();
fields.Add(new ModelField { Name = "A" });
columns.Add(new Column { Text = "A", DataIndex = "A" });
if (X.IsAjaxRequest)
{
Store1.RemoveFields();
fields.ForEach(p => Store1.AddField(p));
}
else
{
Store1.Model[0].Fields.AddRange(fields);
}
Store1.RebuildMeta();
GridPanel1.ColumnModel.Columns.AddRange(columns);
if (X.IsAjaxRequest)
{
GridPanel1.Reconfigure();
}
}
private void BindData()
{
Store1.DataSource = new List<object>()
{
new { A = 10 }
};
Store1.DataBind();
}
protected void OnClick(object sender, DirectEventArgs e)
{
Reconfigure();
BindData();
}
protected void OnCommand(object sender, DirectEventArgs e)
{
X.Msg.Alert("A", "A").Show();
}
[DirectMethod]
public void DmCommand()
{
X.Msg.Alert("B", "B").Show();
}
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="server">
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Grid"
Width="600"
Height="350">
<Store>
<ext:Store
ID="Store1"
runat="server"
IgnoreExtraFields="false">
<Model>
<ext:Model ID="Model1" runat="server" />
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:ImageCommandColumn ID="columnImage" runat="server">
<Commands>
<ext:ImageCommand CommandName="A" Icon="Key" />
</Commands>
<DirectEvents>
<Command OnEvent="OnCommand" />
</DirectEvents>
</ext:ImageCommandColumn>
<ext:ImageCommandColumn ID="ImageCommandColumn1" runat="server">
<Commands>
<ext:ImageCommand CommandName="B" Icon="Add" />
</Commands>
<Listeners>
<Command Handler="#{DirectMethods}.DmCommand({eventMask: { showMask: true }});" />
</Listeners>
</ext:ImageCommandColumn>
<ext:ImageCommandColumn ID="ImageCommandColumn2" runat="server">
<Commands>
<ext:ImageCommand CommandName="B" Icon="Add" />
</Commands>
<Listeners>
<Command Handler="#{DirectMethods}.DmCommand({ eventMask: { showMask: true }});" />
</Listeners>
</ext:ImageCommandColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
</SelectionModel>
<Buttons>
<ext:Button ID="Button2"
runat="server"
Text="Reconfigure">
<DirectEvents>
<Click OnEvent="OnClick" />
</DirectEvents>
</ext:Button>
</Buttons>
</ext:GridPanel>
</asp:Content>
Last edited by Daniil; Mar 06, 2014 at 4:22 AM.
Reason: [OPEN] [#445]