PDA

View Full Version : [CLOSED] Gridpanel columns move with locked = true



PoloTheMonk
Aug 11, 2014, 9:56 AM
Hi,
on loading page I need to move column programmatically.
The code that I use is this


grid.ColumnModel.Move(0, 10)

(move columns with index 0 to position 10)

all work fine, but if in my page there is one or more columns with Locked="True"
I get this error

You have to set widget's ID to call its methods (widget - Ext.Net.GridHeaderContainer)
System.Exception: You have to set widget's ID to call its methods (widget - Ext.Net.GridHeaderContainer)

The problem occours every time that I move a locked column or a non locked column.
Is there a smart solution?

I've tryed to set all columns to Locked="False", move, and reset it to Locked="True" but the new error is this

Uncaught TypeError: Cannot read property 'move' of undefined

Thanks in advance
Polo

Daniil
Aug 11, 2014, 1:29 PM
Hi @PoloTheMonk,

Yes, it might be a problematic scenario, because there are two ColumnModels in a locking GridPanel.

As far as I can understand you need a certain order of columns at the initial load. So, the best solution is to manage a ColumnModel's Columns collection directly.

PoloTheMonk
Aug 11, 2014, 2:32 PM
Hi @Daniil,
I paste here a test page.
When you run it the message is "You have to set widget's ID to call its methods"
How can I do?
Thanks
Polo


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %>
<%
gridTest.ColumnModel.Move(0, 1)
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>test moving columns</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="gridTest" runat="server" Title="Test moving" Border="true">
<Store>
<ext:Store ID="StoreInterventi" runat="server" RemoteFilter="true" AutoLoad="false">
<Model>
<ext:Model ID="ModelTest" runat="server">
<Fields>
<ext:ModelField Name="LOCK1" Type="String"></ext:ModelField>
<ext:ModelField Name="LOCK2" Type="String"></ext:ModelField>
<ext:ModelField Name="LOCK3" Type="String"></ext:ModelField>
<ext:ModelField Name="FREE1" Type="String"></ext:ModelField>
<ext:ModelField Name="FREE2" Type="String"></ext:ModelField>
<ext:ModelField Name="FREE3" Type="String"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModelTest" runat="server">
<Columns>
<ext:Column runat="server" ID="Lock1" DataIndex="LOCK1" Width="150" Text="LOCK1" Align="Left" Locked="true" Hideable="false" Sortable="true"></ext:Column>
<ext:Column runat="server" ID="Lock2" DataIndex="LOCK2" Width="150" Text="LOCK2" Align="Left" Locked="true" Hideable="false" Sortable="true"></ext:Column>
<ext:Column runat="server" ID="Lock3" DataIndex="LOCK3" Width="150" Text="LOCK3" Align="Left" Locked="true" Hideable="false" Sortable="true"></ext:Column>
<ext:Column runat="server" ID="Free1" DataIndex="FREE1" Width="150" Text="FREE1" Align="Left" Sortable="true"></ext:Column>
<ext:Column runat="server" ID="Free2" DataIndex="FREE2" Width="150" Text="FREE2" Align="Left" Sortable="true"></ext:Column>
<ext:Column runat="server" ID="Free3" DataIndex="FREE3" Width="150" Text="FREE3" Align="Left" Sortable="true"></ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

Daniil
Aug 11, 2014, 3:25 PM
Yes, I've reproduced that.

Please clarify have you tried this?

So, the best solution is to manage a ColumnModel's Columns collection directly.

PoloTheMonk
Aug 11, 2014, 3:41 PM
Hi,
but how can I try this?
In my page I have only one ColumnModel...
Thanks!

Daniil
Aug 11, 2014, 3:42 PM
Sorry, I don't quite understand you.

You have a ColumnModel and, respectively, its Columns collection.

gridTest.ColumnModel.Columns

PoloTheMonk
Aug 11, 2014, 5:02 PM
Well, but what can I do with this?


For Each c In gridTest.ColumnModel.Columns
c.???
Next

Is there another method to move columns?
Thank you

PoloTheMonk
Aug 12, 2014, 10:19 AM
I'm sorry @Daniil,
but I can't understand how to use this


gridTest.ColumnModel.Columns

thanks in advance
Polo

PoloTheMonk
Aug 12, 2014, 11:49 AM
I,
I've tried with this



Dim cL As List(Of ColumnBase) = New List(Of ColumnBase)
For Each c As ColumnBase In gridTest.ColumnModel.Columns.OrderByDescending(Fun ction(q) q.DataIndex)
Dim col As ColumnBase = New Column
col.ID = c.ID
col.DataIndex = c.DataIndex
col.Text = c.Text
col.Locked = False
cL.Add(col)
Next
gridTest.Reconfigure(cL)
gridTest.ColumnModel.Move(0, 1)


but it doesn't work, always the same error
Thanks

Daniil
Aug 12, 2014, 3:24 PM
I meant this:

var columns = this.GridPanel1.ColumnModel.Columns;
var col = columns[0];

columns.RemoveAt(0);
columns.Insert(1, col);

PoloTheMonk
Aug 12, 2014, 3:41 PM
You are the man!
Great job!
Thanks!
Polo