Script(s)

what I learn is what u c

Column Locking / Freezing in Infragistics Ultra WebGrid

with 10 comments

(NetAdvantage for ASP.NET)

If you want to freeze first few columns like EXCEL and horizontally scroll rest of the columns in Ultra WebGrid here you go…

Event :

UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)

VB Code :

e.Layout.UseFixedHeaders = true
e.Layout.Bands(0).Columns(1).Header.Fixed = true
e.Layout.Bands(0).Columns(2).Header.Fixed = true

Above code freezes the  two columns (second,third) in Grid.

C# Code

protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
{

e.Layout.UseFixedHeaders = true;
e.Layout.Bands[0].Columns[1].Header.Fixed = true;
e.Layout.Bands[0].Columns[2].Header.Fixed = true;

}
About these ads

Written by gchandra

September 26, 2007 at 8:04 pm

10 Responses

Subscribe to comments with RSS.

  1. [...] Column Locking / Freezing in Infragistics Ultra WebGrid [...]

  2. That didnot work. I searched Infragistics website and found this working..just two lines of code..amazing..

    using Infragistics.WebUI.UltraWebGrid;
    this.UltraWebGrid1.DisplayLayout.StationaryMargins = StationaryMargins.Header;

    Sairam

    January 16, 2008 at 11:15 am

    • I agree. Using the Ultragrid1_InitializeLayout event
      -all you need is one line of code.
      -Ultragrid1.DisplayLayout.StationaryMargins =
      infragistics.WebUI.UltraVewBrid.StationaryMargins.Header

      Dylan Wright

      July 27, 2009 at 9:38 am

  3. I find that both the article code works and Sairam’s code works. However, the former is for preventing columns from scrolling going right to left, while the latter if for preventing column headers from scrolling top to bottom, if that makes sense…

    Andrew

    February 1, 2008 at 12:36 pm

  4. Is there any way to fix a row so that the first row is frozen and you can scroll the remaining rows vertically?

    weltanschauungs

    February 1, 2008 at 4:45 pm

  5. thd above code works fine for freezing columns and headers of the hierarchical webgrid. But its changing the column index of the 3rd band of that hierarchical grid. changing column index means, after getting data from database am binding that to the grid and while retrieving those values from webgrid the column index getting change. please reply me back , its urgent.

    Sagar

    February 8, 2008 at 5:30 am

  6. is there any way to make the parent column width adjusted /synchronised with the child column width if i scroll the child column width in the ultrawebgrid using mouse.

    prabhu

    March 4, 2008 at 10:25 am

  7. Is there any way to fix a row so that the first row is frozen and you can scroll the remaining rows vertically?

    Yes you can use the Initilize event of the grid to set couple of properties. Here is the code:
    te void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
    {
    // The InitializeLayout event is called when the grid binds to data. Many of these
    // settings can be set at design time, rather then run time, via the property window.
    // For this sample, these properties are set in code so that the settings are more easily visible.

    // Turn on addnew and update for the grid
    e.Layout.AllowAddNewDefault = AllowAddNew.Yes;
    e.Layout.AllowUpdateDefault = AllowUpdate.Yes;
    // turn on Fixed Add Row feature
    e.Layout.AddNewRowDefault.Visible = AddNewRowVisible.Yes;

    e.Layout.AddNewRowDefault.View = (AddNewRowView)Enum.Parse(typeof(AddNewRowView), “Top”);

    // The use of StationaryMargins is not required to use AddNewRow. StationaryMargins.Header freezes the ColumnHeaders
    // in place so that they will always be visible regardless of how far the rows of the Grid are scrolled. When the AddNewRow is used
    // the AddNewRow will stay with the stationary header
    if (e.Layout.AddNewRowDefault.View == AddNewRowView.Top)
    {
    e.Layout.StationaryMargins = StationaryMargins.Header;
    }
    else
    {
    e.Layout.StationaryMargins = StationaryMargins.Footer;
    }

    Chaitanya

    September 19, 2008 at 7:28 am

  8. How to Add freez pan in the following infragistic Code

    private void PopulateGrid(string Cadre, string Loc)
    {
    using (TAPServiceClient proxy = new TAPServiceClient())
    {
    DC_Shift[] shift = proxy.GetShiftBySeg(true);
    DC_Emp[] emp = proxy.GetEmps(false, false, string.Empty, string.Empty, string.Empty, string.Empty, Cadre, false, string.Empty, string.Empty, 0, string.Empty, string.Empty, “FirstName”, Loc, false, false, string.Empty, string.Empty, true, string.Empty);
    DataTable objDT = new DataTable(“Emp”);
    objDT.Columns.Add(“EmpId”, typeof(int));
    objDT.Columns.Add(“EmpCode”, typeof(string));
    objDT.Columns.Add(“EmpName”, typeof(string));
    objDT.Columns.Add(“DeptName”, typeof(string));
    if (UltraWebGrid1 != null)
    {
    UltraWebGrid1.Clear();
    }
    int i = 0;
    int j = 0;
    DateTime dtFrom;
    int DaysinM;
    if (DateFrom.IsEmpty == true && DateTill.IsEmpty == true)
    {
    dtFrom = DateTime.Now.FirstDate();
    DaysinM = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);

    }
    else
    {
    dtFrom = DateFrom.SelectedDate.Value;
    TimeSpan ts = DateTill.SelectedDate.Value.Subtract(DateFrom.SelectedDate.Value);
    DaysinM=ts.Days+1;
    }
    if (DaysinM >0)
    {
    string day;
    for (j = 0; j < DaysinM; j++)
    {
    DateTime d = dtFrom.AddDays(j);
    day = d.FormatDay();
    objDT.Columns.Add(d.Day + "-" + day);
    }
    }

    UltraWebGrid1.DataSource = objDT;
    UltraWebGrid1.DataBind();
    ValueList valueList;
    valueList = new ValueList();
    foreach (DC_Shift s in shift)
    {
    valueList.DataSource = shift;
    valueList.ValueMember = "ShiftId";
    valueList.DisplayMember = "ShiftCode";
    valueList.DataBind();

    }
    for (i = 4; i < DaysinM + 4; i++)
    {
    valueList.DisplayStyle = ValueListDisplayStyle.DisplayText;
    UltraWebGrid1.Columns[i].Type = ColumnType.DropDownList;
    UltraWebGrid1.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
    UltraWebGrid1.Columns[i].ValueList = valueList;
    DataBind();
    }
    Session["DT"] = objDT;

    }
    }

    public void PopulateDataTable(string Cadre, string Loc)
    {
    DataTable objDT = new DataTable();
    objDT = (DataTable)Session["DT"];
    DataRow objDR;
    using (TAPServiceClient proxy = new TAPServiceClient())
    {
    DC_Shift[] shift = proxy.GetShiftBySeg(true);
    DC_Emp[] emp = proxy.GetEmps(true, false, string.Empty, string.Empty, string.Empty, string.Empty, Cadre, false, string.Empty, string.Empty, 0, string.Empty, string.Empty, "FirstName", Loc, false, false, string.Empty, string.Empty, true, string.Empty);

    foreach (DC_Emp a in emp)
    {
    DC_Dept[] Dept = proxy.Get(string.Empty, a.EmpOfficial.DeptId.ToString());
    objDR = objDT.NewRow();
    objDR["EmpId"] = a.EmpId;
    objDR["EmpCode"] = a.EmpCode;
    objDR["EmpName"] = a.FirstName + " " + a.LastName;
    objDR["Deptname"] = Dept[0].DeptName;
    objDT.Rows.Add(objDR);
    objDR = objDT.NewRow();
    }
    Session["DT"] = objDT;
    UltraWebGrid1.DataSource = objDT;
    UltraWebGrid1.DataBind();
    UltraWebGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
    UltraWebGrid1.DisplayLayout.Bands[0].Columns[2].Width = 190;
    UltraWebGrid1.DisplayLayout.Bands[0].Columns[1].Width = 80;
    UltraWebGrid1.DisplayLayout.Bands[0].Columns[3].Width = 190;

    }
    }

    SAPNA PERCHANI

    July 6, 2009 at 1:00 am

  9. [...] Locking Cell and Changing Cell Style UltraWebGrid 1Digg meRefer this article for Column Locking / Freezing in Infragistics Ultra WebGrid [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: