Solved

Capture and reassign column order in Infragistics ultragrid

Posted on 2014-02-25
9
1,304 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now