Plugin Developer DiscussionDiscussion for FogBugz Plugin developers |
||
Hi,
While developing a plugin for adding some customer information to a case, I was looking for the possibility to add an event to a SelectInput dialogItem: CBugDisplayDialogItem ddlCustomer = new CBugDisplayDialogItem("Customer"); ddlCustomer.sLabel = FIELD_DISPLAY_NAME; ddlCustomer.sContent = Forms.SelectInput(api.PluginPrefix, customers.ToArray()); CBugDisplayDialogItem ddlCorrespondent = new CBugDisplayDialogItem("Correspondent"); ddlCorrespondent.sLabel = "Correspondent"; ddlCorrespondent.sContent = Forms.SelectInput(api.PluginPrefix + "correspondent", customers.ToArray()); What I want: If the SelectInput Customer is changed, load the other one with the persons who work at the selected company. Data is coming from two different tables in the fogbugz database. Can you please inform me how to add an event for this? Thanks in advance.
It sounds like you want to add a JavaScript "onchange" event. You could do this using the following:
Hashtable attributes = new Hashtable(); attributes["onclick"] = "myFunction();" ddlCorrespondent.sContent = Forms.SelectInput(api.PluginPrefix + "correspondent", customers.ToArray(), null, null, attributes);
Thank you for your quick reply David!
Problem now is, how can I load any new data into the second dropdownlist? Is it possible to do this in the same plugin? Or do I have to do this in a second plugin which is used for sending back the values via javascript?
You can use AJAX to retrieve values from the raw page (IPluginRawPageDisplay) of your plugin. See this wiki page for an example:
https://developers.fogbugz.com/default.asp?W60 In your case you could just return the entire <select> box and insert it into the page. If you encounter a problem where the <select> box is invisible, just call api.DropListControl.refresh(select); where "select" is a reference to the <select> node in the DOM. This will tell our special droplist code to refresh the display of that select box.
David, thanks for your answer, but can you please explain it a bit more?
Where do I put the javascript for calling the IPluginRawPageDisplay part of the plugin for getting the second dropdownlist? In the BugDisplayEditLeft method of the IPluginBugDisplay? Also, api.DropListControl is not available. Thanks in advance.
You can return your JavaScript either inside the HTML in BugDisplayEditLeft, or using an interface like IPluginStaticJS:
https://developers.fogbugz.com/default.asp?W21 api.DropListControl is a client-side API, so it is available in JavaScript code, not in server-side code. |
Powered by FogBugz