如何在GridMvc中设置列文本颜色

时间:2015-10-19 07:36:20

标签: c# model-view-controller viewmodel

这里是我的代码,它位于View Layer中我正在努力改变我的列标题的颜色变为橙色。请帮忙。

@model IEnumerable<uYilo_FMS.Models.vehicle_obj>

@using GridMvc.Html
@{


}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="with=device-width"/>
<link href="@Url.Content("~/Content/Gridmvc.css")" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script>
<script src="@Url.Content("~/Scripts/gridmvc.min.js")"></script>
<rowDefinition Height="57" width="873">

<title>@ViewBag.Title = "Title"</title>
</head>
<body>
<h3>Vehicles List</h3>
<div class="page-wrap">
    @Html.Grid(Model, GridRenderOptions.Create("VehiclesGrid")).Columns(columns =>

{
   columns.Add().Encoded(false).Sanitized(false).RenderValueAs(c => @<img class="thumbnail" src="~/Content/images/@c.ImagePath" height="80" width="80" alt="@c.ImagePath" />);
   columns.Add(c => c.displayName).Titled("Vehicle Name");
   columns.Add(c => c.make).Titled("Make");
   columns.Add(c => c.type).Titled("Type");
   columns.Add(c => c.odometer).Titled("Odometer");




}).WithPaging(5).Sortable(true).

</div>

<script>
    function getRow(vehicle_reg) {
        $.jax({
            url: '@Url.Action("DisplayTripHistory", "Home")',
            data: JSON.stringify(vehicle_reg),
            contentType: 'application/json',
            dataType: 'json',
            type: 'POST',
            success: function () {
                alert('SUCCESS');
            },
            error: function () {
                alert('error');
            }
        }
        );
    }
</script>

1 个答案:

答案 0 :(得分:0)

渲染网格后,您将看到网格使用标题

class CategoriesController < ApplicationController
before_action :find_category, only: [:show]

def index
    @categories = Category.order(:name)
end

def show
end


private

def find_category
    @category = Category.find(params[:id]) 
end

def find_subcategory
    @subcategory = Category.children.find(params[:parent_id])
end

end

类, 所以你可以创建CSS来改变它

示例:

 root      = Category.create("name" => "root")
  child1    = root.children.create("name" => "child1")
  subchild1 = child1.children.create("name" => "subchild1")



root.parent   # => nil
  child1.parent # => root
  root.children # => [child1]
  root.children.first.children.first # => subchild1

您会看到文字标题颜色为红色

要了解更多结帐此链接http://www.codeproject.com/Tips/597253/Using-the-Grid-MVC-in-ASP-NET-MVC

希望它有所帮助!