Feb 11, 2015, 9:18 AM
[CLOSED] RowEditor and RowExpander do not work properly together
There is a Grid that contains a RowEditor and RowExpander.
When the RowExpander is present, the RowEditor does not function, and an error is thrown: "Cannot read property 'lockedGrid' of undefined".
A previously used sample code below:
I am also getting the following error "Cannot read property 'apply' of undefined" when the Grid is loaded.
When the RowExpander is removed, there are no more errors and the Grid and RowEditor work perfectly.
When the RowExpander is present, the RowEditor does not function, and an error is thrown: "Cannot read property 'lockedGrid' of undefined".
A previously used sample code below:
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
function commandHandler(grid, cmdName, record) {
switch (cmdName) {
case 'cmdEdit':
var grid = App.Grid1;
grid.editingPlugin.locked = false;
grid.editingPlugin.startEdit(record);
grid.editingPlugin.locked = true;
}
}
</script>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack && !IsAsync)
{
List<object> userList = new List<object>();
userList.Add(new { id = "1", fullname = "john doe" });
userList.Add(new { id = "2", fullname = "marilyn monroe" });
userList.Add(new { id = "3", fullname = "jack smith" });
userList.Add(new { id = "4", fullname = "andy murray" });
storeName.DataSource = userList;
storeName.DataBind();
}
}
[DirectMethod]
public string GetForm(Dictionary<string, string> parameters)
{
int id = Convert.ToInt32(parameters["ID"]);
string name = Convert.ToString(parameters["FULLNAME"]);
Ext.Net.FormPanel formRowExpander = createRowExpander(id, name);
return ComponentLoader.ToConfig(formRowExpander, true);
}
public Ext.Net.FormPanel createRowExpander(int id, string name)
{
Ext.Net.FormPanel formPanelExpanded = new FormPanel
{
Height = 200,
Width = 290
};
BuildGrid(formPanelExpanded);
return formPanelExpanded;
}
private void BuildGrid(FormPanel frm)
{
Ext.Net.GridPanel grid = new Ext.Net.GridPanel
{
Height = 150,
Width = 557
};
//BUILDING THE STORE
Ext.Net.Store storeIDs = new Ext.Net.Store();
//BUILDING THE MODEL
Ext.Net.Model model = new Ext.Net.Model();
//BUILDING THE MODELFIELDS
Ext.Net.ModelField idfield = new Ext.Net.ModelField()
{
Name = "id",
Type = Ext.Net.ModelFieldType.Int
};
Ext.Net.ModelField title = new Ext.Net.ModelField()
{
Name = "title",
Type = Ext.Net.ModelFieldType.String
};
Ext.Net.ModelField isChecked = new Ext.Net.ModelField()
{
Name = "isChecked",
Type = Ext.Net.ModelFieldType.Boolean
};
//ADDING THE FIELDS TO THE MODEL
model.Fields.Add(idfield);
model.Fields.Add(title);
model.Fields.Add(isChecked);
//ADDING THE MODEL TO THE STORE
storeIDs.Model.Add(model);
//BUILDING THE OBJECTS
List<object> objectList = new List<object>();
objectList.Add(new { id = 1, title = "mr", isChecked = true });
objectList.Add(new { id = 2, title = "ms", isChecked = false });
objectList.Add(new { id = 3, title = "mrs", isChecked = false });
storeIDs.DataSource = objectList;
storeIDs.DataBind();
//ADDING THE STORE TO THE GRID
grid.Store.Add(storeIDs);
//BUILDING THE COLUMNS
Ext.Net.Column columnId = new Ext.Net.Column()
{
DataIndex = "id",
Hidden = true,
Hideable = false
};
Ext.Net.Column columnTitle = new Ext.Net.Column()
{
DataIndex = "title",
Text = "Title",
Flex = 1
};
Ext.Net.CheckColumn columnIsChecked = new Ext.Net.CheckColumn()
{
Text = "Assign",
DataIndex = "isChecked",
Editable = true,
Width = 100
};
//ADDING THE COLUMNS TO THE GRID'S COLUMN MODEL
grid.ColumnModel.Columns.Add(columnId);
grid.ColumnModel.Columns.Add(columnTitle);
grid.ColumnModel.Columns.Add(columnIsChecked);
frm.Items.Add(grid);
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" ID="resourceManager">
</ext:ResourceManager>
<form id="form1" runat="server">
<ext:GridPanel runat="server" ID="Grid1" Height="507" Width="956" EnableLocking="false">
<Store>
<ext:Store runat="server" ID="storeName">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="id" Type="Int" />
<ext:ModelField Name="fullname" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column ID="clnId" runat="server" DataIndex="id" Text="Name" Hidden="true"
Hideable="false" />
<ext:Column ID="clnFullName" runat="server" DataIndex="fullname" Flex="1" Text="Full Name">
<Editor>
<ext:TextField runat="server">
</ext:TextField>
</Editor>
</ext:Column>
<ext:CommandColumn ID="commandColumn" runat="server" Width="50">
<Commands>
<ext:GridCommand ToolTip-Text="Edit"
CommandName="cmdEdit" Icon="ApplicationEdit">
</ext:GridCommand>
</Commands>
<Listeners>
<Command Fn="commandHandler"></Command>
</Listeners>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<Plugins>
<ext:RowEditing ID="RowEditor" runat="server" AutoCancel="false">
</ext:RowEditing>
<ext:RowExpander runat="server" ID="rowExpander">
<Loader ID="Loader1" runat="server" DirectMethod="#{DirectMethods}.GetForm" Mode="Component">
<LoadMask Msg="Loading" ShowMask="true" />
<Params>
<ext:Parameter Name="ID" Value="this.record.data.id" Mode="Raw" />
<ext:Parameter Name="FULLNAME" Value="this.record.data.fullname" Mode="Raw" />
</Params>
</Loader>
</ext:RowExpander>
</Plugins>
</ext:GridPanel>
</form>
</body>
</html>
I am guessing this error is thrown when the isLocked function is called for the RowExpander's expandColumn, but I could be mistaken.I am also getting the following error "Cannot read property 'apply' of undefined" when the Grid is loaded.
When the RowExpander is removed, there are no more errors and the Grid and RowEditor work perfectly.
Last edited by Daniil; Feb 17, 2015 at 1:55 PM.
Reason: [CLOSED]