【问题标题】:MVC WebGrid Column width - not appliedMVC WebGrid 列宽 - 未应用
【发布时间】:2016-06-08 10:01:04
【问题描述】:

参考MVC webgrid column width?

我这里是设置列宽,但是"SNo"没有申请

@grid.GetHtml(tableStyle: "webGrid", headerStyle: "header", alternatingRowStyle: "alternatingrow", 
columns:grid.Columns(
            grid.Column("", style: "button",
                format: 
               @<text>
                    <button class="edit-case read" id="@item.ReferenceID">Edit</button>

                    <button class="update-case edit" id="@item.ReferenceID">Update</button>
                    <button class="cancel-case edit" id="@item.ReferenceID">Cancel</button>
                </text>),
            grid.Column("ParentSNo",canSort:true,
                format:
               @<text>
                    <span id="spanid" class="read">@item.ParentSNo</span>
<input type="text" id="ParentSNo" value="@item.ParentSNo" class="edit" />

                </text>),
 grid.Column("SNo",style: "Large"),
            grid.Column("CAT"),
 grid.Column("Name"),
            grid.Column("MaritalStatus"))


)
</div>
</div>

<style type="text/css">
.Large{
    width: 150px;
}
</style>

提前致谢!

【问题讨论】:

    标签: css asp.net-mvc razor model-view-controller


    【解决方案1】:

    发布您的整体观点会有所帮助。查看下面的示例希望它可能会有所帮助..

    <script type="text/javascript">
      $(function () {
        $("a.postLink").click(function (e) {
          e.preventDefault();
          $.post($(this).attr("href"), function (data) {
          });
        });
      });
    </script>
    
    <h2>Employee Details</h2>
    <style type="text/css">
      .table {
        margin: 4px;
        border-collapse: collapse;
        width: 300px;
      }
    
      .header {
        background-color: gray;
        font-weight: bold;
        color: #fff;
      }
    
      .table th, .table td {
        border: 1px solid black;
        padding: 5px;
    
      }
    </style>
    <div class="test" style="overflow: scroll; width: 1000px">
      @grid.GetHtml(
        tableStyle: "table",
        fillEmptyRows: false,
        headerStyle: "header",
        footerStyle: "grid-footer",
        mode: WebGridPagerModes.All, 
        columns: new[] 
        {
            grid.Column("FileName"),
            grid.Column("EmployeeName"),
            grid.Column("Description","Address"),
            grid.Column("EmailAddress"),
            grid.Column("ContactNumber"),
            grid.Column("EndDate","DateOfBirth",format: item => string.Format("{0:dd-MMM-yyyy}", item.EndDate)),
            grid.Column("Status","Shift"),
            grid.Column("SelectedCityName","Preferred Location"),
            grid.Column("EstimatedCost","Salary",format: (item) => new HtmlString("&#x20B9;"+Convert.ToString(item.EstimatedCost))),
            grid.Column("SelectedCategory","Department"),
            grid.Column("SelectedRequirements","SkillSet"),
            grid.Column("","",format:(item) => @Html.ActionLink("Delete", "Delete", new {Id = item.PId}, new { onclick = "return confirm('Are you sure you wish to delete this record?');" })),
            grid.Column("","",format:(item) => @Html.ActionLink("Edit", "Edit", new {Id = item.PId}))
       })
    
      </div>
    

    【讨论】:

    • 不。帮忙!
    • @Zed 发布您的整个视图,以便我们进行纠正。我认为问题可能只是缺少字符或类似的东西
    猜你喜欢
    • 2016-01-17
    • 2013-07-22
    • 2013-01-07
    • 1970-01-01
    • 2012-03-10
    • 2013-11-28
    • 2014-08-31
    • 2013-02-13
    • 1970-01-01
    相关资源
    最近更新 更多