Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
can the dynamic added column used multicolumn header?
posted

 I add some columns in Page_Load,and want to set multicolumn header in these columns.

in Page_load

var dr = db.ExecuteReader("select id,name from tb_warehouse");
                while (dr.Read())
                {
                    var col = new UltraGridColumn(true)
                                  {
                                      BaseColumnName = ("Quantity" + dr["id"]),
                                      Key = ("Quantity" + dr["id"]),
                                      HeaderText = dr["name"].ToString(),
                                      DataType = "System.Decimal",
                                      AllowUpdate = AllowUpdate.Yes,
                                      Format = "###,###,###.##",
                                      Width = Unit.Pixel(60)
                                  };
                    col.CellStyle.HorizontalAlign = HorizontalAlign.Right;
                    j += 1;
                    col.Header.RowLayoutColumnInfo.OriginX = j;
                    uwgList.Columns.Insert(j, col);

                }
                dr.Close();

 

in InitializeLayout
            foreach (UltraGridColumn c in uwgList.DisplayLayout.Bands[0].Columns)
            {
                c.Header.RowLayoutColumnInfo.OriginY = 1;
            }
            var ch = new ColumnHeader(true);
            ch.Caption = "test";
            ch.RowLayoutColumnInfo.OriginX = 4;
            ch.RowLayoutColumnInfo.OriginY = 0;
            ch.RowLayoutColumnInfo.SpanX = uwgList.Columns.FromKey("sumQuantity").Index -
                                           uwgList.Columns.FromKey("unit").Index;
            e.Layout.Bands[0].HeaderLayout.Add(ch);

foreach (UltraGridColumn c in e.Layout.Bands[0].Columns)
            {
                if ((c.Index <= uwgList.Columns.FromKey("unit").Index) ||
                    (c.Index >= uwgList.Columns.FromKey("sumQuantity").Index))

                {
                    c.Header.RowLayoutColumnInfo.OriginY = 0;
                    c.Header.RowLayoutColumnInfo.SpanY = 2;                

}
            }

 

but these columns's header caption didn't display the "test".

why??