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 would like to control the resources on the custom editing form in code including creating the resource and choosing it for the user. Can someone provide a sample for how to do it? I have tried something like the following... First change the OnClientClick of the save button to my own function that then calls the original function when finished.
function wbSave_OnClick() { var wr = ISGetObject("wcResources"); //create and add a new resource if one is not selected (an existing event) if (wr.Value == "") { ISGetObject("wiResourceName").SetValueData("New Resource"); ISGetObject("wcResourcesColor").SetSelectedIndex(0); ISGetObject("wiRLocation").SetValueData("N/A"); ISGetObject("wiRDescription").SetValueData("New Resource"); WS_OnSaveResource(); //Now select the new row wr.UpdateUI(); wr.Rows[wr.Rows.length - 1].Select(); } //Now call original function and return WS_OnSave(); return true; }
The new row appears in the WebCombo, but I cannot seem to see it in the rows collection right after creating a new one. Is there some other way of getting the resources WebCombo to repopulate?
Glenn,
Well that makes sense! I did not realize that was asynchronous. I made some slight changes, to call the original function only after the resource is set in the timeout function, or otherwise only if the resource is already selected.
var currentItemResourceCount; function wbSave_OnClick() { var wr = ISGetObject("wcResources"); //create and add a new resource if one is not selected (an existing event) if (wr.Value == "") { currentItemResourceCount = wr.Rows.length; ISGetObject("wiResourceName").SetValueData("New Resource"); ISGetObject("wcResourcesColor").SetSelectedIndex(0); ISGetObject("wiRLocation").SetValueData("N/A"); ISGetObject("wiRDescription").SetValueData("New Resource"); WS_OnSaveResource(); wr.UpdateUI(); SetLatestResource(); } else WS_OnSave(); return true; } function SetLatestResource() { var wr = ISGetObject("wcResources"); if (wr.Rows[currentItemResourceCount] != null) { //Now select the new row ISGetObject("wcResources").Rows[wr.Rows.length - 1].Select(); //call original function WS_OnSave(); } else { setTimeout(function() { SetLatestResource(); }, 10); } }
Thanks so much for your help. It is really great to have this kind of flexibility with your control.
In your code, you are using UpdateUI function which is asynchronous and trying to set the combo to the newly added item. Since UpdateUI function is asynchronous, it will take some time to update the UI to relfect the changes. You will need to set some timeout to wait for the WebCombo to refresh. Here is the modified snippet:
var currentItemResourceCount;function wbSave_OnClick() { var wr = ISGetObject("wcResources"); //create and add a new resource if one is not selected (an existing event) if (wr.Value == "") { currentItemResourceCount = wr.Rows.length; ISGetObject("wiResourceName").SetValueData("New Resource1"); ISGetObject("wcResourcesColor").SetSelectedIndex(0); ISGetObject("wiRLocation").SetValueData("N/A"); ISGetObject("wiRDescription").SetValueData("New Resource1"); WS_OnSaveResource(); //Now select the new row wr.UpdateUI(); SetLatestResource(); } //Now call original function and return WS_OnSave(); return true; } function SetLatestResource() { var wr = ISGetObject("wcResources"); if (wr.Rows[currentItemResourceCount] != null) { ISGetObject("wcResources").Rows[wr.Rows.length - 1].Select(); } else { setTimeout(function() { SetLatestResource(); }, 10); } }
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