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
I experience that WebGrid crashes, when the user horizontally scrolls. This happens only when I set the first column to be frozen. It also only happens when I set some columns to hidden (Visible=false).
Attached is a simple sample in VB.NET for that (remove the .txt in the file names). Simplified, the sample contains:
When scrolling, it crashes with: "Microsoft JScript runtime error: 'parentElement' is null or not an object" (Break/Continue/Ignore). The debugger then stands on this JScript code: "var v1d119 =vfcb75.parentElement" (and vfcb75 is null).
I believe this is a bug in WebGrid. We are using the newest WebGrid 6.0.7200.218 and Framework 3.0.5000.705 and the users use Internet Explorer 6 to browse the page.
Can you confirm that this is a bug? If yes, will there be a hotfix available soon? Is there any workaround except not to use freezing or hiding?
Hello Eric,
Here is the fix for your. For your information, this is still a nightly build Hotfix and has not been extensively tested (disclaimer on). So, we are really appreciate if you have encountered an issue can kindly give us a feedback of it.
I hope it helps. Thank you and have a nice day.
Regards,Handy
I also tried with the latest build the same as yours with no issue. I wonder where i was missing at. Btw, i suggest you to use our supported doctype. If i am not mistaken, WebGrid 6 does not supports XHMTL in IE6 yet.
Hi Handy,
First shot: Did you also try with IE6, or did you use any newer version?
Regarding DocType: This is unrelated, as in our project we use:
The other one was there, just because I created a new Visual Studio project and that is the default. BTW: WebGrid should support that also.
Regards,
Eric
Hi Eric,
Yes, i tested on IE6. In fact, WebGrid 6 does not support XHTML. Only from WebGrid7 or higher that supports XHTML doctype. The default format from VisualStudio would automatically create with XHTML doctype. But when you installed our product, the installer should copy our template doctype into VisualStudio.
Please make sure that in Internet Explorer, Internet Options, Advanced, Browsing, "Disable Script Debugging (Internet Explorer)" is NOT checked. Otherwise you won't see that it crashed. After changing this option you might have to restart IE.
Ok, i have unchecked it and i can see the error. But i think that error only occured if you use XHTML doctype. Please try to use our supported doctype instead of XHTML. WebGrid 6 does not support XHTML doctype in IE6. You also have tested with our supported doctype and it worked, correct? So, I can assume this is not an issue in our WebGrid 6 since I already explained.
The sample indeed works when switching to DocType
But unfortunately the error still happens in our project, which does use this correct DocType. I will try to create another sample that uses the correct DocType and still produces this error.
Ok, now I made a new example. It uses the 'correct' HTML 4.0 Transitional DocType and still produces the error. Actually I cannot really see any difference to my first example, but here it occurs. Please have a try at this one.
Hmmm. It looks like something with attachments doesn't work here in the Community. It shows the same files like my initial post.
So here is the new sample again, now with different file names. Please rename them after download (remove the ".txt" and also the "2" in the name). If you don't remove the "2" in the file name you will get a wrong reference (to the first sample).
Hi,
Ok. I can see the issue now. I think you were using incorrect event. Please don't use it at PreRender event, but please try in Initialize_Layout event.
e.g
Protected Sub grdResult_InitializeLayout(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.LayoutEventArgs) Handles grdResult.InitializeLayout SetColumnCaptions(grdResult.RootTable) End Sub
Hello Handy,
When I set the column.Visible flags in the InitializeLayout event, yes it works then. But I cannot do that.
First of all, could you please confirm that this is a bug in WebGrid 6? As far as I know the documentation does not say that I am not allowed to change the Visible column flag in the PreRender event, so it should be allowed and not crash. Either this is a documenation bug or a bug in the WebGrid then.
Regarding your workaround: The SetColumnCaptions Sub mainly changes the column titles (col.Caption). In the real project the new name depends on selections of other controls. If I put this into the InitializeLayout event, the column headers won't get updated anymore. So I separated the Sub into two different ones (SetColumnCaptions and SetColumnVisibility) and called the SetColumnCaptions from the PreRender event and SetColumnVisibility from the InitializeLayout event. In the grid_Export event I call both. This seems to work, but now I have a new problem:
When the grid is empty (no data available, depending on the other controls) then I want to display a custom message in one row telling the user that his selections didn't make sense or there is no data. In that case the InitializeDataSource event creates a New DataSet(), adds all columns necessary and adds one row containing a custom text into the first field. In PreRender I detect this special row again and if found, I increase the width of the first column and make all other columns invisible (Visible = False). This code for setting the visibility is now also in SetColumnVisibility and will not get called, resulting in showing all columns even when there is no data. I only want to show this single error message row and only one column, widened to the whole screen. How can I avoid this problem?
BTW: The refresh of the WebGrid is made this way: The other controls, that cause the content of the WebGrid to change, call their event handler (like SelectedIndexChanged). There I call grid.ClearCachedDataSource() and grid.RebindDataSource(). The WebGrid is in an UpdatePanel and has AsyncPostBackTrigger set to the get triggered from the other controls.
As you can see, I intentionally choosed the PreRender event. This worked until this problem with the crash occured.
And any idea for a workaround for the remaining issue? I mean the problem that I now cannot hide all columns except the first one when there is no data in the resultset.
About your remaining issue, could you please send me a runable simple sample which shows this issue? I need it for firther investigation. It is easier if i could debug it and find which one you are missing or maybe you called those codes or methods in incorrect event. Some possibilities can cause this issue.
Ok, I created a new example. For unknown reasons, this example doesn't crash anymore, but this doesn't matter as it is to show the problems for the workaround.
There's also another bug in the example which causes a popup error message to appear (something with the freezing size). We can ignore that problem also, as it doesn't happen in the real code.
Please make sure to rename the two files after download (remove the "3" and the ".txt").
Issue: When you go to the PreRender event in the vb code and remove the call to SetColumnVisibility to avoid any call to set the .Visible flag in PreRender (in line 69; this is actually your workaround), then, when displaying the "no data" message, all additional columns will still get displayed instead of hidden.
The crash still occurs in your sample. You could not see it because you call SetVisible at PreRender and IntializeLayout. Also some issue happened because IntializeLayout is called before PreRender event. If you try to debug in behind code (server side), there some of your validations or conditions are still incorrect. The reason why the popup error message showed, because you don't set AllowColumnFreezing to no. Please don't forget that there is only one column in that conditions which does not suite with ColumnFreeze.
I modified your sample which i used my workaround and also put some validations inside. It works fine but i don't know if this can help you or not. Please don't hesitate to ask me.
Thanks for your modified sample. When I look at the code, you made the following changes:
- formatting changes
- remove xmlns from html tag
- move UpdatePanel, so that the dropdown ddlChoiceA is now within the UpdatePanel
- event handler for PreRender and ddlChoiceA_SelectedIndexChanged completely removed
- event handler InitializeLayout: call both SetColumnVisibility+SetColumnCaptions from there.
- SetColumnVisibility: set grdResult.LayoutSettings.AllowColumnFreezing flag
- SetColumnVisibility: detect empty resultset by detecting dropdown position instead of content
- SetColumnCaptions: add code to revert changes
I'd like to mention the following issues with your changes:
- You test if the Caption is B or X to set it to A. In reality, the caption contains something like "Current XXX value" or "Tomorrows XXX value" and XXX will get replaced to a word depending on the selection (let's say "red", "blue", "green"). It would be dangerous to add Replace code to detect XXX and all dropdown words to set it to the new word. These words might exist in the captions as well, if there is a caption like "Yesterday's XXX green selection" could get replaced to "Yesterday's red red selection" then. That's why I put this code into PreRender. That's the only place where this problem does not occur. A workaround for this issue would be to not use the Replace command and assign only the complete caption in the code (If ddl=3 then caption5="Yesterday's red green selection" etc.). Or just leave this caption change code in PreRender and the visibility setting in InitializeLayout, like I had it.
- You cannot test the dropdown selection to test if there is data available or not (to set the width etc.). Depending on the dropdown selection different data will be returned in InitializeDataSource (actually a stored procedure database call there). Therefore only the test I had (exactly one row and the first field equals a special text) would work. I know this is not 100% clean and robust code, because the same text could be returned by the database (at least in theory). But for normal cases this is good enough.
So where are your actual improvements?
- Set AllowColumnFreezing flag avoids the popup. Actually in the real project I had no such popup (for whatever reason), but I agree setting this would be a good idea anyway.
I first thought that InitializeLayout event will not get called every time and that's why it didn't refresh the visibility settings. But actually it does get called. The problem is that the data gets refreshed later (InitializeDataSource). Therefore, in InitializeLayout, we don't know yet if we should display all the columns or not (decision if resultset is empty or not). As I mentioned earlier, we cannot just test the dropdown selection. We have to look at the real data returned from InitializeDataSource. But if InitializeDataSource gets called after InitializeLayout, this doesn't help us and means we cannot set the Visibility flags in InitializeLayout.
One workaround would be to call the database in both events. But that is a) bad for performance, which is bad already now, and b) might cause unpredictable results if the database changes between the calls.
Another workaround would be to call the database in InitializeLayout and cache the data until needed in InitializeDataSource. But I think this is too complicated and unreliable (in case InitializeDataSource gets called without a prior call to InitializeLayout).
Any other idea for a workaround to this problem?
- formatting changes- remove xmlns from html tag
Actually, there is no much problem at all with the format. I only try to put it into the correct format. xmlns attribute is used for xhtml format.
- move UpdatePanel, so that the dropdown ddlChoiceA is now within the UpdatePanel- event handler for PreRender and ddlChoiceA_SelectedIndexChanged completely removed
Yes I moved dropdown list within update panel but SelectedIndexChanged is not completely removed. Your scenario are using Update Panel, which sometimes, our control needs to be set inside Update Panel.
I clear all the code within because i saw there is no effect of your codes. You wouldn't need RebindDataSource. The behavior of your scenario is FullPostBack, which is every postback will also called IntializeDataSource again.
- event handler InitializeLayout: call both SetColumnVisibility+SetColumnCaptions from there.- SetColumnVisibility: set grdResult.LayoutSettings.AllowColumnFreezing flag- SetColumnVisibility: detect empty resultset by detecting dropdown position instead of content- SetColumnCaptions: add code to revert changesand some of your scenarios issue that you told me
and some of your scenarios issue that you told me
Yes, i modified your sample based on the previous scenario. If it is more complex scenarios, Of course some validation or conditions could not be used. I only guide you how you supposed to make it work in correct event. The validation and condition of the logic should be worked by you in more complex scenario.I suggest when you want to develop your page, you need to debug the process to see what is the currect value or condition.
IntializeLayout and IntializeDataSource should be called because the page do PostBack. That is the default behavior.
For calling the database again, it should be still on IntializeDataSource event. If you want to recall it, you can use RebindDataSource. If WebGrid has some conditions on it such as cache, you will need to put validation on IntializeDataSource.
Thanks for your reply.
You sound a little like you don't want to answer anymore. If this is the case, just let me know and don't answer anymore. But of course, if I don't get any answer about this bug in your product, this will influence our decision in buying upgrades or future versions from your company. Previously I always got an answer to any problem, even if it sometimes took several weeks and lots of emails to get resolved.
Questions about your last reply and open issues:
- What do you mean with "SelectedIndexChanged was not completely removed"? In your attachment above, the mentioned method is completely empty. Or did I overlook anything?
- Actually a full postback was not intended and only the WebGrid should refresh. I thought that works. Maybe my code or the sample has more problems. But let's focus on the initial problem.
Actually, the only important question that remains is this:
I want to set the column.Visible flag depending on the data I get. I get the data in InitializeDataSource event, as recommended. Afterwards I can access wg.RootTable to find out if there is data. You tell me that I cannot use the PreRender event to set the Visible flag because of a bug in WebGrid. So where should I set the column.Visible flag then? In InitializeLayout it is not possible, because InitializeDataSource has not been called yet, so we don't know to what value to set the flag. This is not a complex scenario. I don't need a new sample, just tell me what to do.
I need a working workaround for this bug.
I apologize if there are something that i said was inappropriate.
Please allow me to explain it more detail for you.
In my sample, the event is not removed. You can put any code that is necessary for your scenario. I discard all the codes inside that event because your codes are not necessary.here is your code:
Protected Sub ddlChoiceA_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlChoiceA.SelectedIndexChanged grdResult.ClearCachedDataSource() grdResult.RebindDataSource() End Sub
As I explained before, your sample do Postback, which will automatically called InitializeDataSource again. RebindDataSource method is meant to be called those events once more.
I understand that full Postback was not intended to. You expect that WebGrid should do refresh.But i am afraid your scenario is not possible to have only refresh.When there is no data, you hide/remove all the columns. In this condition, FreezeColumn could not be used and it will return an alert which you faced. So, you will need to turn off the FreezeColumn and it only can be done with FullPostBack.
Yes, that is also my concern. In fact, there is more efforts to search workarounds for that. My last modified sample also could not work as expected in your current scenario.Some of the validations and conditions could be changed. If we are still using IntializeLayout, we need to get the proper condition and validation to make it works. In your current scenario, i need to look at how the code and lifecycle of your working sample. I could not just get the logic only by the condition that you stated.
Therefore, if my last modified sample are not suitable with your current scenario, I will talk our developer to make the urgent fix. With this way, it can save more your times and efforts.
Please don't missunderstood about what i said before and once again I'm sorry. Please let me know your response.
You didn't say anything wrong. Everything ok.
Regarding the full postback problem: Where does the full postback come from? When I hide/remove columns and use freezing, this doesn't necessarily mean that not just the UpdatePanel gets refreshed. When I call RebindDataSource, I assumed only the UpdatePanel gets refreshed and not the whole page. I still think this should work. If it does not, why? I do understand that not only the grid's content needs to get updated, but also the things around the data etc. But for that reason I placed the UpdatePanel around it. If this is not enough, please let me know why.
Your previous sample does not work for one simple reason: You test if there is no data by checking the dropdown. In reality the dropdown selection is only an input parameter (filter value) for the data that comes from the database in InitializeDataSource. Therefore only there, or afterwards, we really know if there is data available or not. We cannot just test the dropdown. Think about the dropdown as selecting a US-State and the grid content as a list of customers. Perhaps in Utah there are no customers. So we cannot add code to test if dropdown=Utah then display "no data". We have to write the code in a way to test the data itself.
I thought of setting the width of these columns to zero instead of hiding them as a workaround. But this is not a clean solution either, because the user could resize them again or do an export where they reappear etc. If you have any other idea (like another event I could use), please let me know.
Fix: By removing the .Visible flag changes from PreRender to InitializeLayout, I could solve the main problem; it now doesn't crash anymore and we still can use the column freezing. The only problem that remains is that I now cannot hide the extra columns if there is no data, because this cannot be placed into PreRender or anywhere else after InitializeDataSource. This is not nice, but also not critical. If this bug can be fixed within the regular schedule in the next update (I assume within max. 1-2 months), I think this would be sufficient for us.
If i am not mistaken, the fullpostback come from dropdownlist changed selection. Every time, we changed the selection it will do postback.I understand about why you call RebindDataSource. In fact, the page still postback because of the selection of dropdown and i think you still need a postback to do that.
Selected Index Changed event should be called when dropdown list is set into AutoPostback.Update panel/Ajax only shows refresh the content of page or inside UpdatePanel without PostBack the page. But as far i know, the behaviour or lifecycle is not much different when postback.
Yes, I understand about this situation too. My point at previous message was, to guide you about how to use at the correct event or how it works but not to show you how to validate the dropdownlist. (that's my only concern at that time)
I have talked to our developer about this situation. If using the workaround causes more efforts and times, it would better if we wait for the fix.
Please let me know if you have a deadline about the fix. We hope that we can assist you with our best services.
Ok, so we just misunderstood each other. With full postback you meant any type of real postback while I thought of a full page reload. And with refresh you meant client-side refresh of the grid, while I meant a partly postback with Update Panel/AJAX. I just wanted to avoid this screen flickering when reloading the whole page - everything else is ok.
Regarding the fix/using events: So you don't see any other way to handle this. We'll wait for the bugfix in the WebGrid then. There is no special deadline for us. Is my assumption that it will take maximum 1-2 months correct? Please let me know in this thread when this problem is fixed.
Thanks,
Thank you for your response. I will inform you when the fix is ready.
Still no fix available?
It hasn't been resolved yet. I will contact our developer teams and ask them to fix it in the short time.
Here is the new nightly build.FYI, this nightly build has not been tested for regression and we are really appreciate if you might give us feedbacks when you encounter any issues/problems regarding this build.
Thanks for the update. But before testing this, I need some more infos. We just bought the update to version 6 a few months ago. Will this version 7 component work with our license for version 6?
If your build has not been regression tested (whatever this means in detail), then I prefer not to use it on our production system yet. But of course I can test it to give you feedback if it works now.
I thought you were using WebGrid 6. Perhaps, I will need to check it again in WebGrid 6.
FYI, You could not use WebGrid6 license for WebGrid 7.
??? Is this a typo?
Did you want to say that you thought that I was using WebGrid version 7? If your sentence was correct instead, then I don't understand what you wanted to say.
I mentioned the version in my initial mail.
So, I'll wait for more information then.
I am sorry for missunderstanding. Please ignore what I said before. I remembered that you are using WebGrid6. When submitted this bug, I input this into our WebGrid7 (due to our bug submission rules). It seems they forgot to fix in WebGrid 6 as well. I will notify them again.
Thanks for the update. I'll post feedback when I have tested it.
Ok, but please let me know first the update for the current issue. Thank you.
Sorry for the delay in testing this. I couldn't test the beta version on our production system and hoped that in the meantime a new stable version comes out. But as you moved to release 7, it looks like there are no more updates to version 6.
Yes, this hotfix seems to work for my sample. I just updated ISNet.WebUI.WebGrid.dll and ISNet.WebUI.WebGrid.Resources.dll from version 6.0.7200.218 to version 6.0.7200.220 and my sample doesn't crash anymore.
Let me know when the status of your control has made it from "nightly build hotfix" to a stable, tested version.
Thanks for your support.
I am sorry for the late reply. We have not released the official hotfixes. For now, you should use the nightly build hotfixes that I sent before. In next release the fixes should be included as well.
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