I am facing a challenge with pivot grid actually i want to show caption by some other data table Column here is a code that i want to change with DYNAMICVALUE please check.
---------------------------------------------------------------
@Html.EJS().Button("excel").Content("Export To Excel").IsPrimary(true).Render()
@Html.EJS().PivotView("pivotview").Width("100%").Height("290").DataSourceSettings(dataSourceSettings => dataSourceSettings.DataSource((System.Data.DataTable)ViewBag.Data.Tables[0]).ExpandAll(false).EnableSorting(true)
.FormatSettings(formatsettings => { formatsettings.Name("StateName").UseGrouping(true).Add(); })
.Rows(rows => { rows.Name("SecName").Add(); rows.Name("SubSecName").Add(); rows.Name("IndicatorName").Add(); })
.Columns(columns => { columns.Name("StateName").Add(); })
.Values(values => {
values.Name("ColVal1").Caption("DYNAMICVALUE").Add();
values.Name("ColVal2").Caption(" DYNAMICVALUE ").Add();
values.Name("ColVal3").Caption(" DYNAMICVALUE ").Add();
})).GridSettings(new PivotViewGridSettings { ColumnWidth = 140 }).AllowExcelExport(true).Render()
---------------------------------------------------------------------------
please help me out as early as possible
Thanks and regards
RAVI
|
document.getElementById('caption').onclick = function () {
pivotObj = document.getElementById('PivotView').ej2_instances[0];
pivotObj.setProperties(
{
dataSourceSettings: {
values: [{ name: "Sold", caption: "Products Sold" },
{ name: "Amount", caption: "Products Amount" }]
}
},
true
);
pivotObj.refresh();
} |
dataSourceSettings.DataSource((System.Data.DataTable)ViewBag.Data.Tables[0]).ExpandAll(false).EnableSorting(true)
.FormatSettings(formatsettings => { formatsettings.Name("StateName").UseGrouping(true).Add(); })
.Rows(rows => { rows.Name("SecName").Add(); rows.Name("SubSecName").Add(); rows.Name("IndicatorName").Add(); })
.Columns(columns => { columns.Name("StateName").Add(); })
.Values(values => {
values.Name("ColVal1").Caption("Caption1").Add();
values.Name("ColVal2").Caption(" Caption2").Add();
values.Name("ColVal3").Caption(" Caption3 ").Add();
})).GridSettings(new PivotViewGridSettings { ColumnWidth = 140 }).AllowExcelExport(true).Render()
somthing like this with your support
document.getElementById('Caption').onclick = function () {
pivotObj = document.getElementById('pivotview').ej2_instances[0];
pivotObj.setProperties({
dataSourceSettings: {
values: [{ name: "ColVal1", caption: "${Caption1}" }, { name: "ColVal2", caption: "${Caption2}" }, { name: "ColVal3", caption: "${Caption3}" },]
}
},
true);
pivotObj.refresh();
}
----------------------------
i have also tried like this but get the desired results
@Html.EJS().PivotView("pivotview").Width("100%").Height("290").DataSourceSettings(dataSourceSettings => dataSourceSettings.DataSource((System.Data.DataTable)ViewBag.Data.Tables[0]).ExpandAll(false).EnableSorting(true)
.FormatSettings(formatsettings => { formatsettings.Name("StateName").UseGrouping(true).Add(); })
.Rows(rows => { rows.Name("SecName").Add(); rows.Name("SubSecName").Add(); rows.Name("IndicatorName").Add(); })
.Columns(columns => { columns.Name("StateName").Add(); })
.Values(values => {
values.Name("ColVal1").Caption(values.Name("Caption1").ToString()).Add();
values.Name("ColVal2").Caption(values.Name("Caption2").ToString()).Add();
values.Name("ColVal3").Caption(values.Name("Caption3").ToString()).Add();
})).GridSettings(new PivotViewGridSettings { ColumnWidth = 140 }).AllowExcelExport(true).Render()
Thanks and Regards
RAVI
|
$(document).ready(function (e) {
$("#apply-btn").on("click", function (e) {
$.ajax({
url: '/Home/PassIntFromView',
type: "post",
contentType: "application/json; charset=utf-8",
success: function (result) {
var pivotObj = document.getElementById('PivotView').ej2_instances[0];
pivotObj.setProperties(
{
dataSourceSettings: {
values: [
{ name: "Sold", caption: result[0].Caption1 },
{ name: "Amount", caption: result[0].Caption2 },
{ name: "Instock", caption: result[0].Caption3 }]
}
},
true
);
pivotObj.refresh();
}
});
});
}); |