Could anybody explain me Is anyway to implement following using UltraWebGrid?
Thanks
Hello Alexander,
You can achieve such layout and implement custom filtering in UltraWebGrid component. You need to use template columns. In template column you will be able to put template header which can be customized according to your requirements.
General information about UltrawebGrid control you can see here:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/WebGrid_Using_WebGrid.html
Information how to implement Template columns:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/WebGrid_Templating.html
Rado,
Developer support team
Infragistics
Thanks, Rado.
I have tried Header template, and faced with sorting problem. No arrows, no server events when I click on column's header. As I undestand I have to imlement it by myself?
May be there is some way to implement it using multi header? Or some way to change rendering of first row?
Thanks very much for your help!
I have investigated problem.
Header tempate instantiation occurs only after (or on) DataBinding (m_grid.DataBind()).
For example user clicks "Sort" button, in Sort button's event handler I get sorted data and do DataBind() to apply sort condition.
So in my case DataBind() may be occured in every time: Page_Load, Event handlers, Page_Prerender.
But method LoadPostData that loads information from post data occurs only after Page_Load stage So if I do DataBind() after Page_Load, method LoadPostData doesnt occur and my controls in header template loose their state.
For now I do LoadPostData for each control in templates by force. But it is not GOOD solution.
And the question is WHY header tempate controls are instantiated only after DataBind() method?
in addition from help:
Occurs when the grid is being data bound. Called by OnInitializeDataSource. By handling this event the application developers signals to the grid that the UltraWebGrid.DataBind method should be called automatically whenever the data is needed by the grid. No manual call of the method is required after that.
But I need do DataBind manually.
I have changed the code for the example in this way and it works fine.
private void Page_Load(object sender, System.EventArgs e) { // If there is a query string, then this is a custom AJAX call, which means that the user has changed a // DropDownList selection from the Dropdown. if (!Page.IsPostBack){ if (Request.QueryString.Count > 0) { // Filter the DataView applyFilterOnDataView(); isFiltering = true; } }
}
I think that you need to handle in your code this condition to recreate the headers when postback is made in UltraWebGrid1_InitializeDataSource1 method for reference see the sample.
else if (this.IsPostBack && !this.UltraWebGrid1.IsXmlHttpRequest) { // 1: Get the DataView from the session state DataView dv = (DataView)Session["GridDataSource"]; // 2: Create templated columns for DropDownLists to show in each header createDropDownsForRowFiltering(dv); // Since we want the DropDownLists for the header template, we will create all columns in code this.UltraWebGrid1.DisplayLayout.AutoGenerateColumns = false; }
I hope this will help you.
Add one additional question:
If I do data binding in PreRender method my template controls loose their state. Probably it is because state is restored from ViewState after Page_Load but before PreRender. Is anyway to load it by force?
void Page_Load() {InitColumns();}
void Page_PreRender() //controls state is not restored
{
m_grid.DataSource = ds.Tables[0].DefaultView; m_grid.DataBind();
Thanks, Rado!
I have investigated you sample, and faced with following problem:
I dynamically generate columns the same method as in you sample.
The problem is following:
When I do data binding each time all work fine, but if I do binding only on fist request InstantiateIn method did not rised and my column's headers all are empy.
void Page_Load() // Works fine{InitColumns();m_grid.DataSource = ds.Tables[0].DefaultView;m_grid.DataBind();}void Page_Load() //works only on first request{ InitColumns(); If(!IsPostBack) { m_grid.DataSource = ds.Tables[0].DefaultView; m_grid.DataBind(); }}
I cannot (don't want) do data binding on each request.
How can I fix it?
I am afraid that there is no a technical approach to achieve this layout without template column with UltrawebGrid. When you have template columns the grid is not aware what is the content of the columns and it does not know how to filter them. I have sample for you which utilize AJAX functionality of the grid and implements custom filtering with template headers.
Please download and test it
Regards,
Infragistics developer team