Capture and reassign column order in Infragistics ultragrid

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
Larry BiedermanSoftware EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ess KayEntrapenuerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Larry BiedermanSoftware EngineerAuthor Commented:
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
Larry BiedermanSoftware EngineerAuthor Commented:
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
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Ess KayEntrapenuerCommented:
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
Larry BiedermanSoftware EngineerAuthor Commented:
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
Larry BiedermanSoftware EngineerAuthor Commented:
Points increased to 500.
Thanks!
0
Larry BiedermanSoftware EngineerAuthor Commented:
Never heard back about how to alphabetize.
However, the original question was answered with excellent solution.

Thanks, Lbiederman
0
Ess KayEntrapenuerCommented:
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
Larry BiedermanSoftware EngineerAuthor Commented:
I can make this work!
Thanks again - 500 points were awarded.

Thanks, Lbiederman
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.