PDA

View Full Version : [CLOSED] Problem with Grouped Header



ermanni.info
Apr 11, 2013, 3:26 AM

Daniil
Apr 11, 2013, 4:48 AM
Hi Ermanni,


After editing a grouped column an error is generated in the browser: Uncaught TypeError: Can not read property 'persist' of undefined.

I can't reproduce the error. What are exact steps?


The grouped columns do not display the information of the datasource

I don't quite understand you. Please clarify.


I'm using AutoSync in GridPanel.

An edited cell resets because of the fact that you don't handling synchronization. An example is here.
http://examples2.ext.net/#/GridPanel/Update/AutoSave/

ermanni.info
Apr 12, 2013, 2:15 AM
Hi Daniil!

Unfortunately I can not reproduce the problem with a simpler example, as requested by you for analysis. I made the following created a screencast demonstrating the problem and am attaching the output of Firefox (Ctrl + U) to page.

http://www.screencast.com/t/21A68F5H

Note that in the first tab (Geral) data is being displayed correctly. The information on the "Geral" and "Sorologia" have the same origin. It turns out that the values ​​generated automatically in the grid "Sorologia" are not listed for the grouped columns.

When I perform maintenance on these columns the value disappears. Just edit the column that is not grouped (eg "Contra-Prova?") For recorded information being displayed in the grid.

Thanks!

Ermanni

Daniil
Apr 12, 2013, 4:48 AM
Thank you for the screencast. It helps understand the problem, but, unfortunately, I am not sure what you should do to remedy the problems.

Also thank you for the page sources. Though, unfortunately, it is too big for investigating. Passing it via jsbeautifier (http://jsbeautifier.org/) gives 4051 code lines.

So, does your initial sample not reproduce any of those problems?

ermanni.info
Apr 12, 2013, 11:02 AM
No. In the sample code the problem does not occur. I just did the test by removing the columns of the grouping columns and everything returned to normal operation. How do I accomplish creating grouped columns through code. The sample code I posted is correct? There are more recommendations for this practice?

See the excerpt from my class where I create the columns with grouping:



private ColumnBase CreateStringColumn(GridColumn column)
{
var col = column.SummaryType != GridColumnSummary.None ? new SummaryColumn() : new Column();
col.Text = column.Caption;

if (column.Columns.Any())
{
foreach (var gridColumn in column.Columns)
{
col.Columns.Add(CreateColumnProxy(gridColumn));
}
}
else
{
col.ID = column.UniqueName + Id;
col.Align = ConvertAlignment(column.HorizontalAlign);
col.DataIndex = column.DataField;
col.Visible = column.Visible;
col.Flex = (column.Width == 0) ? 1 : 0;
col.Wrap = true;
if (column.Width > 0)
col.Width = Unit.Pixel(column.Width);
if (!column.ReadOnly)
{
var textField = new TextField { AllowBlank = !column.IsRequired, IsRemoteValidation = false };
if (!column.FormatString.IsNullOrEmpty())
textField.Plugins.Add(new InputMask { Mask = column.FormatString });
if (!column.ChangeEvent.IsNullOrEmpty())
{
textField.IsRemoteValidation = true;
textField.RemoteValidation.DirectFn = column.ChangeEvent;
}
if (column.IsValidation)
{
textField.IsRemoteValidation = true;
textField.RemoteValidation.Validation += column.OnValidation;
}
col.Editor.Add(textField);
}
if (HeaderEditable)
col.HeaderItems.Add(new TextField { ID = "h" + column.DataField + Id, Disabled = column.ReadOnly });
if (!string.IsNullOrWhiteSpace(column.ColumnRender))
col.Renderer.Handler = column.ColumnRender;
if (column.SummaryType != GridColumnSummary.None)
{
((SummaryColumn)col).SummaryType = ConvertSummaryType(column.SummaryType);
((SummaryColumn)col).SummaryRenderer.Fn = ConfigureFormat(column);
}
}

return col;
}


There's nothing else in creation. Realize the creation of Column and add new columns in the Columns property based on class ColumnBase. I have methods that create columns according to their type (Column, DateColumn, CheckColumn) but these methods always return the type ColumnBase to be compatible with the grouping columns.

I do not know what to look for. I'm coming to the conclusion not to use this feature.

Thanks!

Ermanni.

Daniil
Apr 12, 2013, 11:21 AM
How do I accomplish creating grouped columns through code.

Sorry, I don't quite understand the requirement. Please elaborate. First of all, please clarify what exactly do you mean under "grouped columns"?

Do you mean this?
http://examples2.ext.net/#/GridPanel/Miscellaneous/ColumnHeaderGroup/

Or the Grouping feature?
http://examples2.ext.net/#/GridPanel/Miscellaneous/Grouping/

ermanni.info
Apr 12, 2013, 11:06 PM
I'm referring to the resource group headers ....

http://examples2.ext.net/#/GridPanel/Miscellaneous/ColumnHeaderGroup/

Baidaly
Apr 13, 2013, 12:41 AM
Hello!

I couldn't reproduce your problem too. Can you try to repeat your in ASPX markup and compare result JS code what you get from CodeBehind and from ASPX. However, the best solution to create simplified example which will give us opportunity reproduce and solve your problem or can help you find problem.

ermanni.info
Apr 14, 2013, 9:35 PM
Hi!

The problem is that with the simplified example the error does not occur. In my application I use to create the grid through code and not by markup. The sample code is at the beginning of this thread and another example of how I create the columns above.

I ask again: what is the best way to create columns and headers grouped GridPanel?

Thanks!

Ermanni

Daniil
Apr 15, 2013, 5:09 AM
I ask again: what is the best way to create columns and headers grouped GridPanel?


Generally, it is the same as it is in the markup. You should populate a Column's Columns collection to get a grouped column with inner columns.

Example

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

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

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object[]
{
new object[] { "test1", "test2", "test3" },
new object[] { "test4", "test5", "test6" },
new object[] { "test7", "test8", "test9" }
};
this.Store1.DataBind();
}
}

protected void RenderGridPanel(object sender, DirectEventArgs e)
{
GridPanel grid = new GridPanel();

Column groupedColumn = new Column()
{
Text = "Some group",
Columns =
{
new Column()
{
DataIndex = "test1",
Text = "Test1"
},
new Column()
{
DataIndex = "test2",
Text = "Test2"
}
}
};

Column simpleColumn = new Column()
{
DataIndex = "test3",
Text = "Test3"
};

grid.ColumnModel.Columns.Add(groupedColumn);
grid.ColumnModel.Columns.Add(simpleColumn);

grid.StoreID = "Store1";

this.Form.Controls.Add(grid);
grid.Render();
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Button runat="server" Text="Render a GridPanel" OnDirectClick="RenderGridPanel" />
</form>
</body>
</html>

ermanni.info
Apr 15, 2013, 10:28 AM
Hi!

Actually there is no secret to create headers grouped! The only difference I noticed in the example was the time to add the columns in the grid. In my class I create the column and now add in the grid. Do not leave anything to add at the end.

I understand the need to provide a simple example that simulates the problem but in this case we are failing. And this situation is more complicated than creating grouped headers is simple and is omitted when the problem does not occur.

My suggestion would be to mount yet another example that makes use of my class for creating grid. Here are many lines of code running a little rule. What do you think?

Thanks!

Ermanni

Daniil
Apr 15, 2013, 12:07 PM
Well, yes, providing us with a sample would be the best option.

Unfortunately, I can't guess what can be wrong.


The only difference I noticed in the example was the time to add the columns in the grid. In my class I create the column and now add in the grid. Do not leave anything to add at the end.

Maybe, you can change my example according this difference to get the issue reproducible?