Hi, I have a grid that I recently upgraded from old Telerik MVC Extensions.
before, the user could select, copy and paste to excel and the styles were keep in Excel.
Now, I'm adding a button to Export to Excel, but styling is not exported.
Is there a way to do that?
@(Html.Kendo().Grid<
ShowNumber
>().Name("GridNumber")
.ToolBar(bar => bar.Excel().Text(Shared.buttonExportExcel))
.DataSource(ds => ds.Ajax().Read(read => read.Action("ReadNumber", "QueryNumbers").Data("getFilter"))
.Columns(columns =>{
columns.Bound(c => c.Description);
columns.Bound(c => c.Initial);
columns.Bound(c => c.Final);
})
.Events(ev => ev.DataBound("volumeDataBound")))
and this is my javascript for changing styles:
function
volumeDataBound(e)
{
var
grid =
this
;
var
currentRecords = grid.dataSource.view();
for
(
var
i = 0; i < currentRecords.length; i++) {
//currentRecords[i] is the current dataItem
var
item = currentRecords[i];
if
(item.DataCorrida==
null
|| item.DataCorrida ==
''
) {
var
tr = grid.tbody.find(
"[data-uid='"
+ item.uid +
"']"
);
tr.find(
"td.k-hierarchy-cell .k-icon"
).removeClass();
}
if
(item.IsShipped) {
grid.tbody.find(
"tr[data-uid='"
+ item.uid +
"']"
).addClass(
"shipped-row"
);
}
else
if
(item.IsRemoved){
grid.tbody.find(
"tr[data-uid='"
+ item.uid +
"']"
).addClass(
"removed-row"
);
}
else
{
grid.tbody.find(
"tr[data-uid='"
+ item.uid +
"']"
).addClass(
"regular-row"
);
}
}
}
Also, I'm not sure if this is the best way to change styles.