WebCombo 4 OnInitialize ClientSideEvents Property Not Rendered

1 reply. Last post: January 11, 2010 2:34 AM by Handy Surya
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
A YousifMember

I have a control that has a WebCombo object within it.  The combo's preselected item is not getting set for whatever reason, i.e., when rendered on the client, it's blank rather than the item value set is selected.  The server-side code confirms that the value is being set.  This is an unbound combo box and the details of this are in the thread here as it's the same control.

Since the preselection of the item I need wasn't working, I decided to try doing it via client side javascript.  I assigned what I needed to OnInitialize but nothing happens and the source of the page shows my method nowhere to be found.  I've tried putting the code below in both the custom control's OnPreRender and the combo's PreRender events but nothing.

I currently have it in the combo's prerender per this code

void m_ComboboxRangeType_PreRender(object sender,EventArgs e)
{
    ((PrismComboBox)sender).LayoutSettings.ClientSideEvents.OnInitialize =
        "jsg_PrismDateRange.DateRangeTypeInit('$controlId','$containerId',$itemIndex,'$itemValue','$itemText');".
        Replace("$controlId",m_ComboboxRangeType.ClientID).
        Replace("$containerId",this.ClientID).
        Replace("$itemIndex",m_ComboboxRangeType.SelectedIndex.ToString()).
        Replace("$itemValue",m_ComboboxRangeType.SelectedText).
        Replace("$itemText",m_ComboboxRangeType.Value);
}

The javascript function looks like this.  I kept the same signature as documented for OnInitialize and retrieved the extra parameters via the arguments collection.  Right now it never gets hit so it's not doing anything.

function DateRangeTypeInit(controlId)
{
    // the control is InterSofts so use ISGetObject
    var oIsCbo = ISGetObject(oIds.cboDateRangeTypeId);
    if (!jsg_PrismUtility.IsVo(oIsCbo))
    {
        return false;
    }

    var idx = 1;
    var containerId = arguments[idx++];
    var itemIndex = arguments[idx++];
    var itemValue = arguments[idx++];
    var itemText = arguments[idx++];
    
    // get the ClientIds object
    var oIds = GetClientIds(containerId);
    if (!jsg_PrismUtility.IsVo(oIds))
    {
        return false;
    }

    oIsCbo.SelectedIndex = itemIndex;
    oIsCbo.SetValue(itemValue);
    oIsCbo.SetTextBoxValue(itemText);
}

I went ahead and put the OnInitialize assignment, for now, in both OnPreRender and the combo's PreRender just to show you the debug value in the attached flash video.

I mainly don't understand why the default value set on the combo box isn't being preselected.  I really shouldn't have to do all this workaround work.  Thanks.

1 attachment
All times are GMT -5. The time now is 8:50 PM.
Previous Next