This is a migrated thread and some comments may be shown as answers.

[Solved] Recognising cells by content when exporting to PDF

1 Answer 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neal
Top achievements
Rank 1
Neal asked on 15 Sep 2009, 08:24 AM
Hi ,

I am trying to (not successfully) To format various cells of the 2 DetailTables in my grid, when exporting to PDF  (using Vers 9.1).

a)  the formatting is not showing (though the code beneath does get entered, execute)
b) stepping thru , shows all cells to have   in them...so checking for 

if (item.Cells[j].Text == "Policy Information")

 

{

....Apply some formatting...
}
    never actually meets the condition and executes.

eg. my  Code from  the "ItemCreated" Event

if

 

( e.Item.OwnerTableView.Name == "ClientSchedDetl" )

 

{

 

if (e.Item is GridDataItem)

 

{

 

int j = 0;

 

 

GridDataItem item = e.Item as GridDataItem;

 

 

foreach (TableCell cell in item.Cells)

 

{

 

 

if (item != null)

 

{

 

 

if (item.Cells[j].Text == "Policy Information")

 

{

item[

"Policy Information"].Style["height"] = "20px";

 

 

//item["EnglishName"].Style["font-weight"] = "bolder";

 

 

//item["Description"].Style["font-size"] = "10px";

 

 

//item["OriginalName"].Style["font-family"] = "Arial Unicode MS";

 

 

//item["OriginalName"].Style["color"] = "#bbbbbb";

 

 

//item["Description"].Style["text-align"] = "center";

 

cell.Style[

"font-family"] = "Arial Unicode MS";

 

cell.Style[

"text-align"] = "left";

 

cell.Style[

"font-size"] = "16px";

 

cell.Style[

"height"] = "24px";

 

cell.Style[

"font-weight"] = "bold";

 

}

 

else

 

{

 

if (j == 0)  //Column One  (no DataKey entries so 0 is the first visble column) MAKE BOLD

 

{

cell.Style[

"font-family"] = "Arial Unicode MS";

 

cell.Style[

"text-align"] = "left";

 

cell.Style[

"font-size"] = "13px";

 

cell.Style[

"height"] = "24px";

 

cell.Style[

"font-weight"] = "bold";

 

}

 

else //Columns two and on..Non-Bold

 

{

cell.Style[

"font-family"] = "Arial Unicode MS";

 

cell.Style[

"text-align"] = "left";

 

cell.Style[

"font-size"] = "10px";

 

cell.Style[

"height"] = "24px";

 

 

//cell.Style["font-weight"] = "normal";

 

}

}

j += 1;

}

}

thanks
Neal

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Sep 2009, 11:17 AM
Hello Neal,

You should use ItemDataBound instead of ItemCreated.

Please examine the following link:
Distinguishing the major differences between ItemCreated and ItemDataBound events

Let me know if you need more information.

Best regerds,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Neal
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or