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
Hi
First problem : WebCombo render empty
I've two webcombo's: Category and Product.
Product is based on Category
In FormView_ItemCreated I set some Value to WebComboCategory and WebComboProduct, but rendered page doesn't show properly WebComboProduct list (there is no Value nor list)
see example
I've tried Select() on my datasource but no result (see comments in example)
Second problem (client side):
On event WebComboCategory_AfterItemSelected I set Text and try to WebComboProduct.LoadValue();
but server doesn't see WebComboCategory.Value.
see javascript example
How can I solve that.
regards
Andrzej
Hi Andrzej,
I think your scenario is more suitable with SetAdditionalFilter scenario (please correct me if i am wrong).I have attached a sample. Hope this helps.
Regards,Handy
Hi,
It's not the same, it's more complicated
I've have to set WebCombo Value in ItemCreated.
Please analyze the event trigger:
onLoad -> _Selecting(FV) -> _Selecting (List) ->_ItemCreated
If you set Value in OnLoad, that's Ok , but If we try set set in ItemCreated it's not working.
In my opinion it's BUG. How can we manualy refresh WebCombo on the server side ?
What exactly the event you used? We don't have any ItemCreated event. Please try to use SetText method in propery way like you did in another thread. e.g SetText("test",true); Also, could you describe more detail about this issue such as in sample or video recording?
To refresh WebCombo, you can do it on both ways.
C# WebCombo1.ClearCachedDataSource(); JavaScript var combo = ISGetObject("WebCombo1"); combo.NeedClearList = true;
In this thread I've described server side events (please look at my example)
protected void FormView1_ItemCreated(object sender, EventArgs e) { if (FormView1.CurrentMode == FormViewMode.Edit) { DataRowView rowView = (DataRowView)FormView1.DataItem; if (rowView != null) { //test binding WebComboCategory.Value = "2";//Condiments WebComboProduct.Value = "3";//Aniseed Syrup } } }
After Page_onLoad method , all WebCombo's on my page start connect to database (trigger method ISDataSourceList_Selecting) before FormView1_ItemCreated. But in this moment there is no any Value in WebComboCategory, so the WebComboProduct list empty, next start FormView1_ItemCreated event and I set some Value to both WebCombo's, I expect to refresh WebComboProduct, but there is no any action on ISDataSourceList_Selecting. I've tried to do that manully using WebComboProduct.ClearCachedDataSource(); , but no result:
//test binding WebComboCategory.Value = "2";//Condiments WebComboProduct.Value = "3";//Aniseed SyrupWebComboProduct.ClearCachedDataSource();// ISDataSourceList_Selecting is't trigger
My question is :
1. Why my render page has WebComboProduct empty ??
2. How ClearCachedDataSource() works ?
The code will work if I set the WebComboProduct value during ItemCreated server side event handler is invoking client script AfterItemSelected. Here is the snippet:
protected void FormView1_ItemCreated(object sender, EventArgs e){ System.Diagnostics.Debug.Print("=====Event : FormView1_ItemCreated : Begin"); if (FormView1.CurrentMode == FormViewMode.Edit) { DataRowView rowView = (DataRowView)FormView1.DataItem; if (rowView != null) { System.Diagnostics.Debug.Print("=====Event : FormView1_ItemCreated : testbinding (Category=2; Product=4)"); WebComboCategory.Value = "2";//Condiments this.ClientScript.RegisterStartupScript(this.GetType(), "Update", "<script type=\"text/javascript\" language=\"javascript\">WebComboCategory_OnAfterItemSelected('');</script>"); } } System.Diagnostics.Debug.Print("=====Event : FormView1_ItemCreated : End");}
The original code will not work because WebComboProduct data source is still empty during the ItemCreated event handler
I'm sorry, but I don't understand. Where would you like to set WebComboProduct.Value to "3" or other value comming from datasource (which is binding to FormView ) ?
We use similar solution with RegisterStartupScript, and set WebComboProduct on the client side, but it's workaround.
Is there no other way ? ... Intersoft have to do that :-)
I think Glenn suggestion is already the best workaround for now. At before, Set Value is not working because the datasource is empty. You can try at simple test. When WebCombo is not binded into any datasource, try to set value. Or you can also setValue with a value which does not in datasource.
How can I manually refresh WebComboProduct, before setting his Value ?
I already told you about how to refresh WebCombo. But if the code is not working, please try to use the additional codes below.
var WebCombo1=ISGetObject("WebCombo1"); WebCombo1.IsDirty = true; WebCombo1.NeedClearList = true; WebCombo1.Values=null; WebCombo1.ClearSelection(); WebCombo1.RefreshValueItems();
Your example explain how to refresh WebCombo on the client side
Maybe I'm not writing clearly or you don't read carefully.
I don't accept method like this:
this.ClientScript.RegisterStartupScript(......
in FormView1_ItemCreated on the server side
I'd like to refresh (prepare) WebCombo in FormView1_ItemCreated before (or after) setting his Value.
Your method WebCombo1.ClearCachedDataSource(); just not working.
I've tried (copy of my first example):
protected void FormView1_ItemCreated(object sender, EventArgs e) { if (FormView1.CurrentMode == FormViewMode.Edit) { DataRowView rowView = (DataRowView)FormView1.DataItem; if (rowView != null) { //test binding WebComboCategory.Value = "2";//Condiments WebComboProduct.ClearCachedDataSource(); //ISDataSourceList.Tables.GetNamedItem("Products").ClearCacheAndData(); //ISDataSourceList.Tables.GetNamedItem("Products").Select(); WebComboProduct.Value = "3";//Aniseed Syrup } } }
My question is : How can I manually refresh WebCombo on the server side ?
To refresh WebCombo from server side, you only need WebCombo1.ClearCachedDataSource(). The only problem is, there is some time out which can also cause InitializeDataSource or ISDataSource selecting not to be called (which i don;t suggest you this way). That's why also need to use client side for the validation (for better performance). There should two workarounds which are SetAdditionalFilter (which i suggest you at first) or using LinkWebCombo.
I have modified your sample and use SetAdditionalFilter in there. You can see that i did not use much behind code. Hope my approach can help you.
Hi Handy,
Thank you for your help, but It's not acceptable method for Product list with few milion records.
SetFilter method don't modify SQL syntax, but set filter only. So app have to receive all records from Product table (it's the most critical point).
We can manually trigger select on any datasource (ie.
ISDataSourceList.Tables.GetNamedItem("Products").ClearCacheAndData(); ISDataSourceList.Tables.GetNamedItem("Products").Select();
Sorry for my embarrassment, but modify WebCombo list on demand should be total base function.
Regards,
I see. So you want it also can be used in Sql syntax or query. If you use SetAdditionalFilter or LinkWebCombo, it would be handled by WebCombo automatically.
For your scenario, i think Glenn approach is already the best workaround for now. But if you still want handle your Sql syntax or query manually, you can set AllowAutoQuesryHandler to false. With this way, you can define your sql query and parameters. Hope this helps. I also attached the sample.
So we have two solutions:
1. by using DataSourceID , then use RegisterStartupScript with JS code which set WebComboProduct Value on the client side and make LoadValue on it
2. by using DataSource (with or without AllowAutoQueryHandler depend on how many rows we expected), then in "FormView1_ItemCreated" set DataSource property to your customdata before or after setting Value on WebComboProduct.
In your example we shouldn't use clear "select * from Products"
I think it should be some method to retrieve list of WebCombo on demand (when the DataSourceId is in use). As you've seen the ClearCachedDataSource not working properly.
Regards
Hi Andrzez,
In my sample, I even did not use ItemCreated event. All i did is in InitializeDataSource. Also,in my sample, i didn't clear "select * from Products". If WebCombo1.Text is "", WebCombo2 would bind based on WebCombo1.Text. Shouldn't this also on demand?
In fact, ClearCacheDataSource is not clear or retrieve the list of WebCombo. Because of this lack, we suggested to also handled it in client side. For now, it is only available on client side.Regards,HAndy
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