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
For further information refere to never solved case IS-5104B939-47A2-40CE-A43D-4A8D67C8B76D from early this year.
I have a page with a WebGrid and FlyPostBack Manager with EnableUIMode="True". The web grid is created dynamicaly on each request, so the number of column is dynamic. I have to color the column headings. Let us say in the first request there are 4 columns with those column headings:
Col1 = BlueCol2 = RedCol3 = YellowCol4 = default color (no color set)
In the second request let us say the columns are only 3 setup in code behind with those colors:
Col1 = BlueCol2 = RedCol3 = default color (no color set)
Unfortunately Col3 now shows up with yellow color (from the first request). To solve this problem I tried something like this as I expected this is happening because the layout of the grid is not posted back to the client (because of the WebFlyPostBack Manager):
//Flypostback event server side
WebFlyPostBackManager1.ClientAction.InvokeScript("SetDefaultStyle()");
//Client side event
function SetDefaultStyle(){var WebGrid1 = ISGetObject("WebGrid1");WebGrid1.RootTable.Columns[2].GetElement().style.backgroundColor = "#D4DDEA";WebGrid1.RootTable.Columns[2].GetElement().style.backgroundImage = "url(ISRes.axd?G/wg5_bk_pro.gif)";}
However that does not help.
Im using 2008 R1 and the webgrid is using "Elegant style".How can I solve this issue?
I am attaching a sample to change datasource with a diffrent column count in WebGrid and setting a different column header color for each datatable.
In the sample the datasource in the WebGrid will be changed using button click and RefreshAll WebGrid method.
The snippet to change the header color using SetDefaultStyle function works without any issue in my environment.
The sample is run on the environment using the latest WebGrid 6 and WebUIFramework 3. Eventough you are using 2008 R1, you are still eligible for WebGrid 6 and WebUIFramework 3 update.
Hi Glenn,
Is there any way to achieve this in JavaScript?
Regards
Hello,I created a WebGrid page, I bound the WebGrid to access data source (Northwind.mdb database & Shippers table).I added a HTML input button to the page and created a JavaScript code to modify the Phone column color into red.Here’s the example snippet code to modify column’s color:
function SetColor(){ var WebGrid1 = ISGetObject("WebGrid1"); WebGrid1.RootTable.Columns[2].GetElement().style.backgroundColor = "Red"; }
I attached the WebGrid page, so that you could see the result furthermore.Hope this helps.Regards,Hans K.
Hi Hans,
Thanks for your reply.
I am trying to add the background colour to the header when column is added from the context menu.
I tried to add the code provided by you as shown below, but its throwing JavaScript error “Unable to get property 'style’ of undefined ornull reference”.
function OnColumnChanged(controlId, tblName, colName, action){
if(action == "Added")
if(ISGetObject(controlId).RootTable.GetColumn(colName).AllowGrouping == "Yes") {
ISGetObject(controlId).RootTable.GetColumn(colName). GetElement().style.backgroundColor = "Red";
}
} }
Can you please tell what’s wrong with this implementation and a way to achieve the given scenario?
Regards Dev
Hello,Thank you for the reply.I tried to modify your code so that it can resolve your issue. I add setTimeout() method to your code. Here’s the how I add the setTimeout() method:
function WebGrid1_OnColumnChanged(controlId, tblName, colName, action){ if (action == "Added") { if (ISGetObject(controlId).RootTable.GetColumn(colName).AllowGrouping == "Yes") { window.setTimeout(function () { ISGetObject(controlId).RootTable.GetColumn(colName).GetElement().style.backgroundColor = "Red"; }, 100); } } }
Please kindly have review on the attached page & video about the result of this workaround.Hope this helps.Regards,Hans K.
Thanks for the workaround. It solved my problem.
But this is not working if I use the “Reset” option in thecontext menu.
On grid initiation I am setting the background colour for the Header now if the user removes the column and add it back the colour should come back as well.
Using the “OnColumnChanged” event I am able to handle the “Apply” click but I am not getting any event for “Reset” click.
Please suggest a solution.
Hello,The “Reset” event will cause the WebGrid will do postback event. It won’t call “OnColumnChanged” client side event.So I modified the attached WebGrid page, by adding “OnInitializeLayout” server side event to the WebGrid.In “OnInitializeLayout” event, I add a line of code to modify “Phone” column header color to “Red”.Here’s the snippet code:
protected void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e){ WebGrid1.RootTable.Columns.GetNamedItem("Phone").HeaderStyle.BackColor = System.Drawing.Color.Red; }
I attached the modified page as well. Please let me know your response.Regards,Hans K.
Thanks for sample code.
The solution provided by you works fine.
Thanks, Dev
Hello,Thank you for the confirmation.I’m glad to hear that the solution works fine on your end.Should you have further question, please do not hesitate to contact us.Regards,Hans K.
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