Solved

Capture and reassign column order in Infragistics ultragrid

Posted on 2014-02-25
9
1,358 Views
Last Modified: 2014-05-21
Hi Experts,

Using Infragistics ultragrid, I need to allow user to change the column order, then capture this order, so user can return it to this order in future.

I can capture the column order in vb.net using:

For x = 0 To 100
             tmp = tmp & UltraGrid1.DisplayLayout.Bands(0).Columns(x).Key & ","
Next x

         Using writer As New IO.StreamWriter(fileNameOutput)
            writer.WriteLine(tmp)
            writer.Close()
        End Using

However, if I rearrange the columns in grid (by drag and drop) it does not change the column order.

How can I capture and reassign the actual visible order of columns?

Thanks Much
LBiederman
0
Comment
Question by:Larry Biederman
  • 6
  • 3
9 Comments
 
LVL 15

Accepted Solution

by:
Ess Kay earned 500 total points
ID: 40013487
infragistics has a save feature. you need to save it to a file and load it next time the grid opens.
You also need to enable this feature



Me.ultragrid.DisplayLayout.Override.allowRowFiltering = true

DIM FILENAME = "c:\gridsettings.xyz"
 Me.ultragrid.DisplayLayout.Save(filename)
 Me.ultragrid.DisplayLayout.load(filename)


i use this when you leave and enter grid

    Private Sub ultragrid_Leave(sender As Object, e As System.EventArgs) Handles ultragrid.Leave
        Me.ultragrid.DisplayLayout.Save(filename)
    End Sub

Open in new window

0
 

Author Comment

by:Larry Biederman
ID: 40045965
Hi  esskayb2d,
Sorry for the delay in responding (was away from work).

I'll give a try this week and award points.

Thanks so Much,
Larry
0
 

Author Comment

by:Larry Biederman
ID: 40052373
Hi  esskayb2d,

Hurray!  That works fine!
Strangely, I had to omit:   Me.ultragrid.DisplayLayout.Override.allowRowFiltering = true
But when I used remaining code it works as advertized.
You will receive all 400 points for this.

One expansion to this question:
I looked at the actual file created and it is complex.
Anyway I can cause columns to be sorted alphabetically by column name?
Not field name (tag) but actual header caption.
I'm using VB.net 2013, and Infragistics 13.2 with its latest service pack.

I'll increase answer to 500 points if you also solve this.

Thanks Much,
Lbiederman
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 15

Expert Comment

by:Ess Kay
ID: 40054035
Sure. the sort will also be saved in the files.
Simply click the column you want sorted, click the collumn again to sort in reverse order. A third time will remove sorting
, and when its saved, you will see it in the file
(This requires that you allow sorting in the grid properties)

Anything you do with the grid will be saved, and it will look like that when loaded

furthermore, if you use one grid multiple times, you need to save files seperatly

IE,      
DIM gridtype as string
Private Sub getgridType() as string
return "c:\gridsettings" & gridtype & ".xyz"
End Sub

Private Sub a()
    gridtype =  "gridA"  
   ....ultragrid.datasource = somedatasource...
Me.ultragrid.DisplayLayout.load(getgridType())
End Sub

Private Sub b()
    gridtype =  "gridB"  
   ....ultragrid.datasource = somedatasource...
Me.ultragrid.DisplayLayout.load(getgridType())
End Sub

 Private Sub ultragrid_Leave(sender As Object, e As System.EventArgs) Handles ultragrid.Leave
        Me.ultragrid.DisplayLayout.Save(filename)
 End Sub

Open in new window

0
 

Author Comment

by:Larry Biederman
ID: 40055364
Thanks for response!

What I desire to do is have a button I can click on, that will save the entire grid, alphabetically, in order of 'header captions'.
So if column header captions are currently ordered:  "lastname", "firstname", "address", the user can click a button to save (then recall),
the columns so they appear in alphabetical order:  "address", "firstname", "lastname" (alphabetical order).

In other words.. is there a way to display the entire grid, sorted by column headers, in alphabetical order?
Don't want to do manually, but with a click or two.

Thanks much for your expertize !!

lBiederman
0
 

Author Comment

by:Larry Biederman
ID: 40055368
Points increased to 500.
Thanks!
0
 

Author Closing Comment

by:Larry Biederman
ID: 40068198
Never heard back about how to alphabetize.
However, the original question was answered with excellent solution.

Thanks, Lbiederman
0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 40068605
Sure. the sort will also be saved in the files.


But user will have to click the header at least once to set the order, after that it will be auto


Or, you can specify that in your SQL query or datasource  :
Order BY column1, column2 column3 desc

Open in new window


However, if you do the order in the backend, and user sorts by a column, the column with overwrite the backend sort, the frontend sort will take presidence
0
 

Author Comment

by:Larry Biederman
ID: 40080759
I can make this work!
Thanks again - 500 points were awarded.

Thanks, Lbiederman
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question