WebGrid中的上下文菜单

时间:2015-07-20 11:12:53

标签: c# asp.net-mvc webgrid

我在我的MVC项目中使用WebGrid,我想在该WebGrid中右键单击(在行单击上)添加上下文菜单。那么,有谁可以请帮助我如何在我的webgrid中添加上下文菜单和选择上下文菜单项,如何检索ID?以下是更详细的代码:

@using (Html.BeginForm("save", "Inventory"))
{
    var grid = new WebGrid(Model.products, canSort: false, canPage: true, rowsPerPage: 3);
    int rowNum = 0;

    <div>
        @grid.GetHtml(tableStyle: "webGrid", alternatingRowStyle: "alt", headerStyle: "header",
            selectedRowStyle: "select",
        columns: grid.Columns
            (
               grid.Column("RowNumber", format: item => rowNum = rowNum + 1, style: "rowno"),

               grid.Column("Id", 
               format: (item) => Html.TextBox("products[" + (rowNum - 1).ToString() + "].Id", 
                   (object)item.Id, new { @readonly = "readonly" }), 
                   style: "id"),

              grid.Column("Name", format: (item) => Html.TextBox("products[" + (rowNum - 1).ToString() + "].Name", (object)item.Id), style:"name"),
                                                                                                                      grid.Column("Description", format: (item) => Html.TextBox("products[" + (rowNum - 1).ToString() + "].Description", (object)item.Description), style: "desc"),
                                                                                                          grid.Column("Quantity", format: (item) => Html.TextBox("products[" + (rowNum - 1).ToString() + "].Quantity", (object)item.Quantity), style: "qty"),
                                                                                                          grid.Column("QualityType", format: @item => Html.DropDownList("products[" + (rowNum - 1).ToString() + "].QualityType", (IEnumerable<SelectListItem>)Model.products[rowNum - 1].QualityTypeModel), style: "qlty")
                  ), mode: WebGridPagerModes.Numeric)

    </div>
    <input type="submit" value="Submit">
}

1 个答案:

答案 0 :(得分:0)

最近,我使用jQuery Context Menu实施了类似的任务。 结果如下

31

Demo jQuery Context Menu