0

1

I'm currently working with CDialogTemplate to display a pop-up edit window with Selection Dropdowns. However, I cannot get the template to select an option using the hashdata template.

For example, my template has a select menu defined as:

 new CDialogItem(Forms.SelectInputString("SelectedOwner", Forms.SelectOptions(owners, "{selectedOwner}", ownersValue)),
                    "Owner", "{selectedOwner}")

Then, when adding the template, I set selectedOwner to the value I want selected. The instructions get set to the value, however, the selection box defaults to the first selection.

I suspect it's because the SelectInputString looks for the selected option to be of the given values, and since the param {selectedOwner} isn't a value, it's skipped. Also, how would this even work since a selected item just has selected appended to the option tag. Not really a replace strategy that would work easily here.

Is there a way to do this?

flag

3 Answers

1

I have updated the Editable Table article on developers.fogbugz.com with bitbounce's fix. Here's a quick template:

In DialogTemplateEdit():

CDialogItem itemEdit = new CDialogItem("{selectOptions}",
    "My Field Name",
    "Choose a widget from the drop-down.");
dlgTemplateEdit.Template.Items.Add(itemEdit);

Now put the entire html string for the drop-down in the hashtable:

for (int i = 0; i < myDataTable.Rows.Count; i++)
{
    ixKiwi = Convert.ToInt32(dsKiwis.Tables[0].Rows[i]["ixKiwi"]);
    // ixZoo is the id of the Zoo that will be in the drop-down
    ixZoo = Convert.ToInt32(dsKiwis.Tables[0].Rows[i]["ixZoo"]);
    Hashtable hashData = new Hashtable();
    hashData.Add("ixKiwi ", ixKiwi);
    // call a method to generate the drop-down html for this row's ixZoo value
    hashData.Add("selectOptions", GetZooSelect(ixZoo));
}

protected string GetZooSelect(int ixZooSelected)
{
    string sSelectInputString = "";
    int nZoocount = zooTable.Rows.Count;
    zooNames = new string[nZooCount];
    zooIxs = new string[nZooCount];
    for (int i = 0; i < nZooCount; i++)
    {
        zooNames[i] = zooTable.Rows[i]["sZooName"].ToString();
        zooIxs[i] = zooTable.Rows[i]["ixZoo"].ToString();
    }

    sSelectInputString = Forms.SelectInputString(api.AddPluginPrefix("ixZoo"),
                                                 Forms.SelectOptions(zooNames,
                                                                     ixZooSelected.ToString(),
                                                                     zooIxs));
    return sSelectInputString;
}
link|flag
0

It turns out that the best way to approach this situation is to not setup your selectinput in the dialog template. Instead, add a dialog item as follows to your template:

new CDialogItem("{selectItem}");

Then, when you populate the templates hashtable data for each row/item you are using it for:

new Hashtable { {"selectItem", Forms.SelectInputString(Prefix + "SelectedStuff", Forms.SelectOptions(displayOptions, selectetItemValue, displayValues))}};
link|flag
0

Hi, Thanks for the suggestion! but struggling a bit for implementing these lines...please post a crisp example as it may help us in great way.

Thanks,

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.