iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello,
I found what seems to be an issue with the font in the grid.
When changing the style of a row and a cell programmatically the text does not get the correct font. Instead of the font used in the WebGrid it gets the standard font of the page.
As an example:
<style type="text/css"> body { font-family: Monospace; } </style> <ISWebGrid:WebGrid ID="WebGrid1" runat="server" DefaultStyleMode="Silver" UseDefaultStyle="true"> </ISWebGrid:WebGrid>
And in code behind:
bool isEvenRow = true; void WebGrid1_InitializeRow(object sender, RowEventArgs e) { if (isEvenRow) e.Row.Style.BackColor = System.Drawing.Color.LightGray; bool isEvenColumn = true; foreach (WebGridCell cell in e.Row.Cells) { if (isEvenRow && isEvenColumn) cell.Style.BackColor = System.Drawing.Color.Yellow; isEvenColumn = !isEvenColumn; } isEvenRow = !isEvenRow; }
This example will change the background color of every even row (gray) and every even cell (yellow). At least for me the yellow cells will have Monospace as font while the rest of the cells will have the WebGrid font.
Is there a solution to this?
Regards,
David
Hi David,
In this example, the changes will not be occured since we are using the default style. With this sets to true, it will take the default style as an important style and replace the other (which we declared on the outside of WebGrid).
In your case, to have the font changes only for the yellow cells, we can simply add the font family during the InitializeRow server side event. Here is the snippet in order to do so:
protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { if (isEvenRow) e.Row.Style.BackColor = System.Drawing.Color.LightGray; bool isEvenColumn = true; foreach (WebGridCell cell in e.Row.Cells) { if (isEvenRow && isEvenColumn) { cell.Style.BackColor = System.Drawing.Color.Yellow; cell.Style.Font.Name = "Monospace"; } isEvenColumn = !isEvenColumn; } isEvenRow = !isEvenRow; }
I also attached you my screenshot of this snippet, kindly take a look if it meets your scenario. I hope it can help you. Thank you and have a nice day.
Best Regards,
Andi Santoso
The thing is that I want the font to stay the same as the rest of the grid. And the problem is that the font changes anyway when I set any other style (like the background property) on the row and on the cell.
I used the Monospace font on the page body to illustrate the problem that occurs in the grid.
I attached a screenshot which looks pretty much like yours. However, I have not set the cell font to Monospace. It happens anyway.
Forgive me, however I am not able to replicate your issue. Even when I set the style for the page body without set the font in InitializeRow, WebGrid will overwrite the style with its default style which in this case, the font will be using Segoe UI. At this moment, I am using WebGrid version 7 build 403.
However, if you set the font family like I did (during the InitializeRow), does it also changes the font when you set any other stlye on the row on on the cell ?
I hope it helps. Thank you and have a nice day.
Doh! I missed the 403 build. After I applied the hotfix it works as it should!
Sorry, my mistake. Thanks for your help.
/David
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname