Hi.
I have a grid with a attendance records:
@using (Html.BeginForm("Index", "HRRecord",FormMethod.Post))
{
}
created="created" rowHeight="22" locale="@(System.Globalization.CultureInfo.CurrentCulture.Name)">
foreignKeyValue="LastName" dataSource=ViewBag.Persons width="120">
foreignKeyValue="FirstName" dataSource=ViewBag.Persons width="120">
width="160">
width="120">
width="100">
........................................................................
All fields is correctly completed with data from controler.
I have 2 questions:
1). - How can change background color for columns (dxx) for weekend days in function of month and year (from controller if is possible)?
2). - Is possible to hide column d31 (d30,d29) for months with fewer days?
thanks in advance for big help.
|
<ejs-grid id="Grid" dataSource="ViewBag.datasource" allowPaging="true">
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column>
<e-grid-column field="OrderDate" headerText=" Order Date" textAlign="Right" format="yMd" width="130"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" width="120"></e-grid-column>
<e-grid-column field="ShippedDate" headerText="Shipped Date" textAlign="Right" format="yMd" width="140"></e-grid-column>
<e-grid-column field="ShipCountry" visible="false" headerText="Ship Country" width="150"></e-grid-column>
</ejs-grid> |
|
<div>
<ejs-grid id="Grid" dataSource="ViewBag.DataSource" beforeDataBound="beforeDataBound" allowPaging="true">
<e-grid-pagesettings pageCount="4" pageSize="5"></e-grid-pagesettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" customAttributes="@(new { @class=ViewBag.customAttribute } ) " width="150"></e-grid-column>
. . .
</e-grid-columns>
</ejs-grid>
</div>
. . .
<style>
.e-background,.e-background.e-headercell{
background: #d7f0f4;
}
</style> |
|
public IActionResult Index()
{
ViewBag.DataSource = OrdersDetails.GetAllRecords().ToList();
ViewBag.customAttribute= "e-background"; |
|
<div>
<ejs-grid id="Grid" dataSource="ViewBag.DataSource" beforeDataBound="beforeDataBound" allowPaging="true">
<e-grid-pagesettings pageCount="4" pageSize="5"></e-grid-pagesettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" customAttributes="@(new { @class=ViewBag.customAttribute } ) " width="150"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" format="N2" width="120"></e-grid-column>
<e-grid-column field="OrderDate" headerText="Order Date" type="date" format="yMd" width="150"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
var isInitial = true;
function beforeDataBound(args) {
var grid = this;
// using flag variable for preventing the execution more than once
if (isInitial) {
isInitial = false;
// here we are iterating the grid current view data and hiding the particular column based on the data value
for (var i = 0; i < args.result.length; i++) {
if (args.result[i].Freight > 5) {
grid.hideColumns(["Freight"]);
break;
}
}
}
}
</script> |
You are the Best!
Thank you very much for help.