• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1109
  • Last Modified:

button on ultragrid

I have a Ultragrid which has 3 levels of hierarchy.
I want to add a button on third level of hierarchy for each row in a separate column.
what kind of code or process should I to follow?
0
Masterabhi
Asked:
Masterabhi
  • 2
1 Solution
 
Jens FiedererTest Developer/ValidatorCommented:
Here's an easy example for a page with just a single grid on it.

Most of the code is just to set up the 3-level dataset, the important part is marked in a comment.
protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            DataTable t1 = TextTable(new string[] { "countryid", "countryname" });
            AddRow(t1, new string[]{"1", "Germany"});
            AddRow(t1, new string[] { "2", "France" });
            DataTable t2 = TextTable(new string[] { "countryid", "stateid", "statename" });
            AddRow(t2, new string[] { "1", "1", "Hessen" });
            AddRow(t2, new string[] { "1", "2", "Niedersachsen" });
            AddRow(t2, new string[] { "1", "3", "Berlin" });
            AddRow(t2, new string[] { "1", "4", "Bremen" });
            AddRow(t2, new string[] { "1", "5", "Hamburg" });
            AddRow(t2, new string[] { "1", "6", "Bayern" });
            AddRow(t2, new string[] { "1", "7", "Franken" });
            AddRow(t2, new string[] { "2", "21", "Alsace" });
            AddRow(t2, new string[] { "2", "22", "Aquitaine" });
            AddRow(t2, new string[] { "2", "23", "Basse-Normandie" });
            AddRow(t2, new string[] { "2", "24", " Bourgogne" });
            AddRow(t2, new string[] { "2", "25", " Bretagne" });
            AddRow(t2, new string[] { "2", "26", "Limousin" });
            DataTable t3 = TextTable(new string[] { "stateid", "cityid", "cityname" });
            AddRow(t3, new string[] { "1", "1", "Frankfurt" });
            AddRow(t3, new string[] { "21", "2", "Strasbourg" });
            AddRow(t3, new string[] { "21", "3", "Wittenheim" });
            AddRow(t3, new string[] { "21", "4", "Colmar" });
            ds.Tables.Add(t1);
            ds.Tables.Add(t2);
            ds.Tables.Add(t3);
            ds.Relations.Add(t1.Columns[0], t2.Columns[0]);
            ds.Relations.Add(t2.Columns[1], t3.Columns[0]);
            UltraWebGrid1.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.OutlookGroupBy;

            // important part below!
            UltraGridColumn buttonColumn = new UltraGridColumn("but", "buttton", ColumnType.Button, "Press");
            buttonColumn.NullText = "Press";
            buttonColumn.CellButtonDisplay = CellButtonDisplay.Always;
            buttonColumn.CellButtonStyle.Width = Unit.Pixel(100);
            buttonColumn.CellButtonStyle.Height = Unit.Pixel(30);
            UltraWebGrid1.DataSource = ds;
            UltraWebGrid1.DataBind();
            UltraWebGrid1.Bands[2].Columns.Add(buttonColumn, false);
            UltraWebGrid1.Bands[0].ExpandAll();
            UltraWebGrid1.Bands[1].ExpandAll();
            UltraWebGrid1.Bands[2].ExpandAll();
        }

        public void AddRow(DataTable t, IEnumerable<string> fields)
        {
            DataRow row = t.NewRow();
            int i = 0;
            foreach (string field in fields) {
                row[i++] = field;
            }
            t.Rows.Add(row);
        }

        public DataTable TextTable(string[] names)
        {
            DataTable output = new DataTable();
            foreach (string name in names)
            {
                output.Columns.Add(name);
            }
            return output;
        }

Open in new window

0
 
MasterabhiAuthor Commented:
Thanks.
0
 
MasterabhiAuthor Commented:
helped me
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now