Search results

Apply condition based hyperlink for specific row or column

You can apply conditions for specific row or column using label option to show hyperlink option in the pivot grid. It can be configured using the conditionalSettings option through code behind, during initial rendering. The required settings are:

  • label: Specifies the header name to get visibility of hyperlink option for row or column.
  • condition: Specifies the operator type such as equals, greater than, less than, etc.
  • value1: Specifies the start value.
  • value2: Specifies the end value.
razor
LabelConditions.cs
@Html.EJS().PivotView("PivotGrid").Height(300).DataSource(dataSource => dataSource.Data((IEnumerable<object>)ViewBag.Data).ExpandAll(false)
.DrilledMembers(drilledmembers =>
{
    drilledmembers.Name("Country").Items(ViewBag.countryMembers).Add(); drilledmembers.Name("Year").Items(ViewBag.yearMembers).Add();
}).Rows(rows =>
 {
     rows.Name("Country").Add(); rows.Name("Products").Add();
 }).Columns(columns =>
 {
     columns.Name("Year").Caption("Production Year").Add(); columns.Name("Quarter").Add();
 }).Values(values =>
 {
     values.Name("Sold").Caption("Units Sold").Add(); values.Name("Amount").Caption("Sold Amount").Add();
 })).HyperlinkSettings(hyperlinksettings => hyperlinksettings
 .ConditionalSettings( format =>
{
    format.Conditions(Condition.Between).Label("Germany").Value1(500).Add();
})).Render()
public ActionResult Index()
{
    var data = GetPivotData();
    ViewBag.data = data;
    ViewBag.yearMembers = new string[] { "FY 2015" };
    ViewBag.countryMembers = new string[] { "France" };
    return View();
}