This is a migrated thread and some comments may be shown as answers.

[Solved] Delete Command Issue in Grid

2 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daryl Shenner
Top achievements
Rank 1
Daryl Shenner asked on 12 Jan 2012, 10:00 AM
Hi Team,

We are experiencing the following issue while using the Delete button column in the Grid

We need to have a Delete column in the grid to delete the row. But Unfortunately, when I add the delete command, my grid getting splitted. Kindly provide us the right direction as soon as possible. Here is the code on creating/binding grid:

< table style="height:100%;">
<tr>
<td colspan="5">
@Html.Telerik().Grid(CommentsLog).Name("gridCommentsLog").DataKeys(dataKeys => dataKeys.Add(o => o.QuoteID)).ToolBar(commands => { commands.Insert().ButtonType(GridButtonType.Image); commands.SubmitChanges().ButtonType(GridButtonType.Image); }).DataBinding(dataBinding => dataBinding.Ajax().Select("GetCommentsLogDetails", "InventoryHome").Update("SaveCommentsLog", "InventoryHome")).Columns(columns =>
{
columns.Bound(o => o.QuotesCommentsLogID).Title("QuotesCommentsLogID").Hidden(true);
columns.Bound(o => o.QuoteID).Title("QuoteID").Hidden(true);
columns.Bound(o => o.LogUserName).Title("User").Width(40).ReadOnly(true);
columns.Bound(o => o.LogDateTime).Title("Date").Width(120).ReadOnly(true);
columns.Bound(o => o.Comments).Title("Comments");
columns.Command(commands => commands.Delete().ButtonType(GridButtonType.Image)).Title("Delete");
}).RowAction(row =>
{
// "DataItem" is the Order object to which the current row is bound to
if (row.DataItem.QuotesCommentsLogID != null)
{
//Set the background of the entire row
row.HtmlAttributes["disabled"] = "disabled";
}
}).CellAction(cell =>
{
if (cell.Column.Title == "Delete")
{
cell.HtmlAttributes["style"] = "visibility:hidden";
}
}).ClientEvents(events => events.OnEdit("onEdit")).Editable(editing => editing.Mode(GridEditMode.InCell).DefaultDataItem(new QuotesCommentsLogModel { LogUserName = SessionHandler.UserName, LogDateTime = DateTime.Now.ToShortDateString() })).Pageable(paging => paging.PageSize(10).Style(GridPagerStyles.NextPreviousAndDropDown)).Selectable().HtmlAttributes(new { style = " font-family:arial; font-size: .7em; width:800px;" })
</td>
</tr>
</table>

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 13 Jan 2012, 03:48 PM
Hello Daryl,

The most likely reason for the Grid being split is if it is in a form element. The delete command creates a form itself and nested forms are not supported.
If this is the case you should move the Grid out of the form. If not, I will need a sample project which reproduces this in order to investigate further.

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Wahaj
Top achievements
Rank 1
answered on 21 Feb 2012, 07:38 AM
Thanks Daniel

You make life easier. Its Works...
Tags
Grid
Asked by
Daryl Shenner
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Wahaj
Top achievements
Rank 1
Share this question
or