如何定制并使贡献网格变得时尚

发布于 2024-10-03 06:18:20 字数 1136 浏览 7 评论 0原文

到目前为止,我已使用此编码来查看我的 mvc contrib 网格...这里,当我绑定网格时,它变得太大,最后一列超出了页面...请说明如何减小大小并使 网格有些多么时尚......

<%= Html.Grid<Product>(Model)
           .Columns(column => 
          {

        column.For(c => c.ProductID);
        column.For(c => c.ProductName);
        column.For(c => c.SupplierID);
        column.For(c => c.CategoryID);
        column.For(c => c.QuantityPerUnit);
        column.For(c => c.UnitPrice);
        column.For(c => c.UnitsInStock);
        column.For(c => c.UnitsOnOrder);
        column.For(c => c.ReorderLevel);
        column.For(c => c.Discontinued);
        column.For(c => Html.ActionLink("Details", "Details", new { id = c.ProductID })).InsertAt(0).Encode(false);
        column.For(c => Html.ActionLink("Edit", "Edit", new { id = c.ProductID })).InsertAt(1).Encode(false);
        column.For(c => Html.ActionLink("Create", "Create", new { id = c.ProductID })).InsertAt(2).Encode(false);
        column.For(c => Html.ActionLink("Delete", "Delete", new { id = c.ProductID })).InsertAt(3).Encode(false);
          }
    )



%>

So far i have used this coding for view formy mvc contrib grid....here the when i bind grid it becomes too large it the last column is going outside of the page...pls say how to reduce the size and make the
grid some how stylish.....

<%= Html.Grid<Product>(Model)
           .Columns(column => 
          {

        column.For(c => c.ProductID);
        column.For(c => c.ProductName);
        column.For(c => c.SupplierID);
        column.For(c => c.CategoryID);
        column.For(c => c.QuantityPerUnit);
        column.For(c => c.UnitPrice);
        column.For(c => c.UnitsInStock);
        column.For(c => c.UnitsOnOrder);
        column.For(c => c.ReorderLevel);
        column.For(c => c.Discontinued);
        column.For(c => Html.ActionLink("Details", "Details", new { id = c.ProductID })).InsertAt(0).Encode(false);
        column.For(c => Html.ActionLink("Edit", "Edit", new { id = c.ProductID })).InsertAt(1).Encode(false);
        column.For(c => Html.ActionLink("Create", "Create", new { id = c.ProductID })).InsertAt(2).Encode(false);
        column.For(c => Html.ActionLink("Delete", "Delete", new { id = c.ProductID })).InsertAt(3).Encode(false);
          }
    )



%>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨巷深深 2024-10-10 06:18:20

以下是我如何使用交替的行和颜色来设计网格样式。

<%Html.Grid<UserSummaryModelDetails>(Model.Users)
    .Columns(column =>
                {
                    column.For(x => x.FullName).Named("Name").Attributes(x => new Dictionary<string, object> { { "valign", "top" } });
                    column.For(x => x.Division).Attributes(x => new Dictionary<string, object> { { "valign", "top" } });
                })
                .RowStart((p,row)  => {     
                                        if (!row.IsAlternate) { %>
                                            <tr class="gridrow_alternate">
                                        <%  }  else  { %>
                                            <tr>
                                        <% }
                            })
        .HeaderRowAttributes(new Dictionary<string, object> { { "style", "height: 25px;" } })
        .Empty("No users found")
        .Attributes(@class => "table-list")
        .Render();
%>

样式表:

.table-list
{
    clear: both;
    width: 800px;
    height: 100%;
      border: solid 1px #e8eef4;
      border-collapse: collapse;
      overflow: visible;
      margin-top: 10px;
}

.table-list td 
{
  padding: 5px;   
  border: solid 1px #e8eef4;
  overflow: visible;
}

.table-list tr 
{
    height: 95px;
    overflow: visible;
}

.table-list th
{
  padding: 6px 5px;
  text-align: left;
  background-color: #e8eef4; 
  border: solid 1px #e8eef4;  
  overflow: visible;
}


.table-list .gridrow_alternate
{
    background-color: #eee;
}

Here's how I style my grids with alternatings rows and colors.

<%Html.Grid<UserSummaryModelDetails>(Model.Users)
    .Columns(column =>
                {
                    column.For(x => x.FullName).Named("Name").Attributes(x => new Dictionary<string, object> { { "valign", "top" } });
                    column.For(x => x.Division).Attributes(x => new Dictionary<string, object> { { "valign", "top" } });
                })
                .RowStart((p,row)  => {     
                                        if (!row.IsAlternate) { %>
                                            <tr class="gridrow_alternate">
                                        <%  }  else  { %>
                                            <tr>
                                        <% }
                            })
        .HeaderRowAttributes(new Dictionary<string, object> { { "style", "height: 25px;" } })
        .Empty("No users found")
        .Attributes(@class => "table-list")
        .Render();
%>

Style sheet:

.table-list
{
    clear: both;
    width: 800px;
    height: 100%;
      border: solid 1px #e8eef4;
      border-collapse: collapse;
      overflow: visible;
      margin-top: 10px;
}

.table-list td 
{
  padding: 5px;   
  border: solid 1px #e8eef4;
  overflow: visible;
}

.table-list tr 
{
    height: 95px;
    overflow: visible;
}

.table-list th
{
  padding: 6px 5px;
  text-align: left;
  background-color: #e8eef4; 
  border: solid 1px #e8eef4;  
  overflow: visible;
}


.table-list .gridrow_alternate
{
    background-color: #eee;
}
放飞的风筝 2024-10-10 06:18:20

您可以为每列定义宽度或自定义 CSS 类。这样你就可以限制它的大小:

column.For(c => c.ProductID)
      .Attributes(gr => new Hash(@width => "15%"));

或者CSS类:

column.For(c => c.ProductID)
      .Attributes(gr => new Hash(@class => "productId"));

你也可以将整个网格放入一个固定宽度的div中。

You could define a width or a custom CSS class for each column. This way you can restrict its size:

column.For(c => c.ProductID)
      .Attributes(gr => new Hash(@width => "15%"));

or a CSS class:

column.For(c => c.ProductID)
      .Attributes(gr => new Hash(@class => "productId"));

You could also put the entire grid into a div with fixed width.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文