Вопрос

Is there a way to merge these two columns? This is what I have right now enter image description here. This is how I created these two columns from code-behind

                        GridEditCommandColumn EditColumn = new GridEditCommandColumn();
                        this.RadGrid1.MasterTableView.Columns.Add(EditColumn);
                        EditColumn.ButtonType = GridButtonColumnType.ImageButton;
                        EditColumn.UniqueName = "EditCommandColumn";
                        EditColumn.HeaderText = "SingleAction";
                        EditColumn.ColumnGroupName = "test";

                        GridButtonColumn DeleteColumn = new GridButtonColumn();
                        this.RadGrid1.MasterTableView.Columns.Add(DeleteColumn);
                        DeleteColumn.CommandName = "Delete";
                        DeleteColumn.ButtonType = GridButtonColumnType.ImageButton;
                        DeleteColumn.UniqueName = "DeleteCommandColumn";
                        DeleteColumn.ConfirmDialogType = GridConfirmDialogType.Classic;
                        DeleteColumn.HeaderText = "SingleAction";
                        DeleteColumn.ConfirmText = "Do you really want to delete?";

Now I want to achieve something like this enter image description here I have tried to do the GridCalculatedColumn like this

GridCalculatedColumn calcol = new GridCalculatedColumn();
calcol.DataFields =new string[]{"EditCommandColumn","DeleteCommandColumn"};
calcol.Expression ="{0}-{1}";
tableViewProjects.Columns.Add(calcol);

But, I cannot achieve what I want. I get an error column [EditCommandColumn] does not exist, which I think makes sense, because it not a data field from the database. So, is there a way to achieve this.

Please help, Thank you in advance

Это было полезно?

Решение

I got the solution from the Telerik help. The link for the same is

http://www.telerik.com/community/forums/aspnet-ajax/grid/merging-edit-and-delete-columns-in-radgrid.aspx

Thank you all

Другие советы

The telerik RadGrid is "some kind" of DataGrid and offers the same options

One of these options is the itemtemplate.

You can put any html-element in that template. This code is stolen from that answer:asp.net gridview: How can I have multple button fields in one column?

but should also work with telerik

<ItemTemplate>
                <asp:LinkButton ID="btnApprove" runat="server" CommandName="Approve" Text="Approve" />
                <asp:LinkButton ID="btnDeny" runat="server" CommandName="Deny" Text="Deny" />
                <asp:LinkButton ID="btnReturn" runat="server" CommandName="Return" Text="Return" />
            </ItemTemplate>

To get more "telerik specific" help, "radgrid itemtemplate" should help you on the telerik knowledgebase

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top