Solved

Capture and reassign column order in Infragistics ultragrid

Posted on 2014-02-25
9
1,449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

734 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