I have found that for the telerik provided skins that produce a border around the cell, for example Inox which just has a horizontal border, I must change blank values to to see that border when the value is blank.
Is there a better way to handle this situation where I must change the value in itemdatabound to get the border to show?
ex:
if
(dataView["CodeDesc"].ToString().Trim().Length == 0)
{
dataitem[
"CodeDesc"].Text = " ";
}
16 Answers, 1 is accepted
Can you try with the following code snippet?
CS:
protected void RadGrid2_PreRender(object sender, EventArgs e) |
{ |
foreach (GridDataItem dataItem in RadGrid2.Items) |
{ |
foreach (GridColumn col in RadGrid2.Columns) |
{ |
if (dataItem[col.UniqueName].Text == string.Empty) |
dataItem[col.UniqueName].Text += " "; |
} |
} |
} |
Thanks
Princy.
Princy,
Thanks for the reply. Your suggestion would simply move what I already have in itemdatabound to prerender althoough it would do this in one step rather than for each item.
What I was looking for was a way that this could be done without any code on my part given the fact that Telerik's design point seems to be "create a grid without any coding on your part" which I really like. I just thought I was missing a tag attribute or somethng clever that Telerik has alrady done for this case.
I guess they have not so I will keep my itemdatabound handler code as is.
Thanks again.
The latest versions of RadGrid for ASP.NET and RadGrid for ASP.NET AJAX add " " strings to empty data cells automatically. Are you using some old version of the control?
Greetings,
Dimo
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Hello Dimo,
I am using the 2008.1.515.35 of Telerik.Web.UI.dll. Further investigation of my data query revealed that the column in question returned a ' ' (single blank) and not a NULL as I think you were expecting.
If I changed the query in the select from simply returning the column to
case RTRIM(A.CODEDESC) WHEN '' then NULL ELSE A.CODEDESC END as CODEDESC
the ' ' will now be returned as a NULL and your code works as described in your post.
I have found that I needed to add the RTRIM SQL function to handle blank columns with a length more than 1, for example ' '.
I have the same problem. I'm using the IE7 and the latest version of the controls. When the cell of the grid has no value, it shows no border around the cell.
I tried the workaround with the  , but I have templates in my grid. If I try the   workaround all cells are blank.
Do you have another solutions for this?
Thanks
Tommy
Are you sure that you are appending the string to the template cells? Maybe you are replacing the cell content and that is why the cells are blank,
When using templates, the easiest way is to simply add unconditionally the string at the end of the template.
Regards,
Dimo
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thanks Dimo.
When I add a " " to my cell and I export it to PDF, the " " string is in each column of the PDF. When I export it to word or to excel I don't have the string in it.
Can you help me to solve this problem. Thank you.
Excel interprets this character as html code unlike in PDF where it is shown like plain text. You can avoid this using a simple flag, indicating that you are currently exporting to PDF file. This will help you add   only when applicable, i.e.:
bool isPdfExport = false; |
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == RadGrid.ExportToPdfCommandName) |
{ |
isPdfExport = true; |
} |
} |
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
what I mean is, I add the string " " to my cells to get a border around each cell where I have a database NULL value in it.
Currently when I'm exporting the grid data to excel or word the " " is not shown, only when I'm exporting to PDF.
What I want is, that I don't see the " " string in the PDF.
Thanks
Thomas
The idea of the code shown below is to use a flag to indicate when you are exporting PDF. This is needed in order to prevent the useless " " to be put into your PDF document. Instead the   workaround you can set RadGrid1.GridLines = GridLines.Both; or GridLines="Both" to explicitely show the grid lines.
Please try the suggested code and let us know if you need further assistance.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
the solutions with RadGrid1.GridLines = GridLines.Both; or GridLines="Both" doesn't work.
When I remove " " and set the Gridlines to both, there are still no gridlines.
Any Idea?
Thomas
For your convenience I attached a sample website illustrating the mentioned approach.
Greetings,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I am using version 2008.3.1314.20 and using the above suggested code in the prerender event in order to add a nbsp ( ) to empty column fields so the column grid line is displayed in IE. It works fine for the first page load, but for some reason on the postback of an outside control (that does nothing more than do the postback), the column grid lines are missing again for the empty fields although when I debug the prerender event the nbsp exist in all empty fields.
Any ideas? Thanks
You can use the PreRender event of the grid to ensure that the symbols will be added to the cells on each postback. Another solution would be to intercept the ItemDataBound event of the grid and inject the empty symbol there:
http://www.telerik.com/community/forums/aspnet-ajax/grid/border-not-displayed-if-cell-is-empty-in-internet-explorer.aspx
and call the Rebind() method of the grid on postbacks from other controls on the page. Thus the ItemDataBound event will be raised and the value will be inserted as expected.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Hi Sebastian,
Thanks for the alternative solution. But my problem was that i wasn't calling the Rebind() method from the other controls as you suggested and that sorted my problem.
Best regards
Justin