TypedList problem in ultra grid

Posts   
 
    
sekobey
User
Posts: 12
Joined: 24-Mar-2005
# Posted on: 24-Mar-2005 12:58:47   

Hello there, I use adapter scenario in my project and i use a typed list that is binded to a grid.I looked at columns of typed list that they are correct with designer.But when i run the program i see duplicate columns in my ultra grid like below:

Column Name: CompanyNo CompanyCode ... COMPANYNO COMPANYCODE

My Code is like this:


sirketKartiTypedList = new SirketKartiTypedList();
DataAccessAdapter adapter = new DataAccessAdapter();
IRelationPredicateBucket bucket = (IRelationPredicateBucket)sirketKartiTypedList.GetRelationInfo();
adapter.FetchTypedList(sirketKartiTypedList.GetFieldsInfo(),
        sirketKartiTypedList,bucket,0,false);
this.sirketUDG.DataSource = sirketKartiTypedList;
adapter.CloseConnection();

Any help?please...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Mar-2005 13:24:33   

In the initializelayout event handler, could you please check if you get twice the columns there? It should work, the typed list is a datatable, after all.

Frans Bouma | Lead developer LLBLGen Pro
sekobey
User
Posts: 12
Joined: 24-Mar-2005
# Posted on: 24-Mar-2005 13:43:22   

Otis wrote:

In the initializelayout event handler, could you please check if you get twice the columns there? It should work, the typed list is a datatable, after all.

Sorry but i am not much with familliar with what you said.What is initializelayout event handler and where is it.I couldn't find any match in my code.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Mar-2005 13:50:34   

sekobey wrote:

Otis wrote:

In the initializelayout event handler, could you please check if you get twice the columns there? It should work, the typed list is a datatable, after all.

Sorry but i am not much with familliar with what you said.What is initializelayout event handler and where is it.I couldn't find any match in my code.

The ultra grid has an initializelayout (or similar) event which is fired when the grid initializes right before the columns are shown. In there you can see which columns are added and if needed you can hide them. I'm no expert on the ultragrid though.

Frans Bouma | Lead developer LLBLGen Pro
sekobey
User
Posts: 12
Joined: 24-Mar-2005
# Posted on: 24-Mar-2005 13:58:38   

But i build data grid in run-time.At first no initialization available.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Mar-2005 14:29:03   

sekobey wrote:

But i build data grid in run-time.At first no initialization available.

Please check the events of the grid, you can set an event handler for that grid's initialize routine.

If you have an empty grid, and you simply set teh datasource to the typed list, no columns designed, do you still get duplicate columns?

Frans Bouma | Lead developer LLBLGen Pro
sekobey
User
Posts: 12
Joined: 24-Mar-2005
# Posted on: 24-Mar-2005 14:42:24   

yes

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Mar-2005 14:48:44   

sekobey wrote:

yes

You get duplicate columns, even though there are NO columns designed in the grid? I've seen strange stuff with ultragrid but not this... hmm...

Frans Bouma | Lead developer LLBLGen Pro
sekobey
User
Posts: 12
Joined: 24-Mar-2005
# Posted on: 24-Mar-2005 15:05:38   

yes, i design columns in run-time.i try it in normal windows data grid and it gave me same result.I don't know what i will do

sekobey
User
Posts: 12
Joined: 24-Mar-2005
# Posted on: 24-Mar-2005 15:07:52   

Should i use a data member or any other thing?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Mar-2005 15:43:33   

Well the ultragrid always displays ALL columns in a datasource, unless some property is set to true (though that's only in the newest versions I believe, I have no details on that). In the event handler I talked about (the handler you have to define for that initialize event) you can hide columns you don't want. That's the way I solved it with this grid. (binding to whatever, doesn't matter, it always shows all columns). A datamember isn't required I believe, as you bind to a single datatable, so there is just one datatable.

Frans Bouma | Lead developer LLBLGen Pro
sekobey
User
Posts: 12
Joined: 24-Mar-2005
# Posted on: 24-Mar-2005 19:05:22   

it's strange that my typed list does not contains duplicate columns.It contains normal number of columns.So everything is normal before running the program.But after running,it becomes duplicate.Has ever anybody in this forum encounter this problem?

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 24-Mar-2005 19:52:00   

I use the Infragistics grid quite a bit. This problem mostly happens when columns are created for the grid at design time, then bound to a datasource where the column names or order don't line up. It doesn't always happen, and I'm not sure what exactly causes it, but removing the design-time columns always fixes it for me.

Jeff...

alitozan
User
Posts: 1
Joined: 25-Mar-2005
# Posted on: 25-Mar-2005 00:17:31   

Hiding the columst that you dont want to see solves the problem but i cannot change the captions of the colums. for example The column Name is COMPANY_NAME but i want to set this caption Company Name. I change the caption but hidden column affected by this. so there is no way to change the captions. is there any way to handle this problem ? Also can i make queries by not using typedlists becouse it seems that this problem wont be solved , nfortunately

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 25-Mar-2005 09:56:31   

alitozan wrote:

Hiding the columst that you dont want to see solves the problem but i cannot change the captions of the colums. for example The column Name is COMPANY_NAME but i want to set this caption Company Name. I change the caption but hidden column affected by this. so there is no way to change the captions. is there any way to handle this problem ? Also can i make queries by not using typedlists becouse it seems that this problem wont be solved , nfortunately

You can set the caption of a column by setting: grid.DisplayLayout.Bands[0].Columns["columnname"].Header.Caption to a text.

You can also re-order the columns this way. Here's a piece of code I use in the Entity field grid in the entity editor:


_fieldsGrid.DisplayLayout.Bands[0].Columns["FieldName"].Header.VisiblePosition = 0;
_fieldsGrid.DisplayLayout.Bands[0].Columns["FieldIndex"].Header.VisiblePosition = 1;
_fieldsGrid.DisplayLayout.Bands[0].Columns["DotNetType"].Header.VisiblePosition = 2;
_fieldsGrid.DisplayLayout.Bands[0].Columns["IsReadOnly"].Header.VisiblePosition = 3;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldFieldName"].Header.VisiblePosition = 4;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldDBTypeAsString"].Header.VisiblePosition = 5;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldLength"].Header.VisiblePosition = 6;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldPrecision"].Header.VisiblePosition = 7;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldScale"].Header.VisiblePosition = 8;
_fieldsGrid.DisplayLayout.Bands[0].Columns["IsPrimaryKeyField"].Header.VisiblePosition = 9;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldIsNullable"].Header.VisiblePosition = 10;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldIsComputed"].Header.VisiblePosition = 11;
_fieldsGrid.DisplayLayout.Bands[0].Columns["MappedFieldIsTimeStamp"].Header.VisiblePosition = 12;
_fieldsGrid.DisplayLayout.Bands[0].Columns["IsIdentity"].Header.VisiblePosition = 13;
_fieldsGrid.DisplayLayout.Bands[0].Columns["IdentityValueSequenceName"].Header.VisiblePosition = 14;
for (int i = 0; i < _fieldsGrid.DisplayLayout.Bands[0].Columns.Count; i++)
{
    if(_fieldsGrid.DisplayLayout.Bands[0].Columns[i].Key == "FieldIndex")
    {
        // do not resize
        continue;
    }
    _fieldsGrid.DisplayLayout.Bands[0].Columns[i].PerformAutoResize(PerformAutoSizeType.VisibleRows);
}

Frans Bouma | Lead developer LLBLGen Pro
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 25-Mar-2005 17:52:07   

I wrote a routine to hide columns and reorder. Here it is:

     Public Shared Sub ShowCols(ByRef band As UltraGridBand, ByVal colsToShow() As String, _
        ByVal cellActivation As Activation)

        Dim Col As UltraGridColumn
        Dim Position As Integer
        Dim ColKey As String
        Dim Count As Integer

        ' Hide all columns except ones in colsToShow.
        For Each Col In band.Columns
            Position = Array.IndexOf(colsToShow, Col.Key)
            If Position = -1 Then
                Col.Hidden = True
            Else
                Col.CellActivation = cellActivation
            End If
        Next

        ' Change column position to match the same as colsToShow.

        Try
            For Each ColKey In colsToShow
                band.Columns(ColKey).Header.VisiblePosition = Count
                Count += 1
            Next

        Catch ex As Exception
        End Try

    End Sub

You call it like this:

             Dim Cols() As String = {"GradeLevel", "InitialSound", "LetterNaming", "PhonemicSegmentation", "NonsenseWord", "OralReading"}
            uiHelper.ShowCols(grdDibels.DisplayLayout.Bands(0), Cols, Infragistics.Win.UltraWinGrid.Activation.ActivateOnly)

The Cols array is the columns you want to display arranged in the order you want them.

HTH

Fishy