Is there Autopostback for Multicolumncombobox cells like there is for Combobox?

Posted by: klgrube on 8 September 2017, 11:52 am EST

    • Post Options:
    • Link

    Posted 8 September 2017, 11:52 am EST

    I see that there is an Autopostback option for the Combobox cell type, but I don’t see that option available for the Multicolumncombobox cell type. Can the column containing the multicolumncombox cell type be set to autopostback? I have a multiclumncombo box in column 1 of a sheet and I need for a postback to occur when the datavalue is changed (when the user makes a selection from the dropdown). How can I generate a postback when that happens? Please let me know.

  • Posted 8 September 2017, 11:52 am EST

    Hello,

    You can handle the onDataChanged event client side and raise a postback by calling the Update() method.

    This onDataChanged event is fired when data of a cell is changed at client side. Please have a look at the code below:

    [js] var spread1;

    window.onload = function () {

    spread1 = document.getElementById(“<%=FpSpread1.ClientID %>”);

    if (document.all) {

    // IE

    if (spread1.addEventListener) {

    // IE9

    spread1.addEventListener(“DataChanged”, dataChanged, false);

    } else {

    // Other versions of IE and IE9 quirks mode (no doctype set)

    spread1.onDataChanged = dataChanged;

    }

    }

    else {

    // Firefox

    spread1.addEventListener(“DataChanged”, dataChanged, false);

    }

    }

        function dataChanged(event) {
            
            alert("The data changed!");
            //for multicolumncombobox column
            if (spread1.GetActiveCol == 1)
            { spread1.Update();}
           
        }
    

    [/js]

    I hope it helps!

    Thanks,

    Deepak Sharma

  • Posted 8 September 2017, 11:52 am EST

    So, the basic answer is that there is no simple autopostback flag for the multicolumncombobox. I hope this is being planned for the next release. It would make things so much simpler.

    Thank you so much for the code! I assume this code goes in a “script” at the top of the ASP.net page. I’m sorry for not mentioning that this is going in on web page. If that makes a difference, please let me know.

    The spread I’m working with has two sheets, each of which uses a multicolumncombobox. The multicolumncombobox is used in column 1 of both sheets. I’m not sure if I need to put in two sets of code for two different sheets in the same spread or if the above code will work to handle both sheets.

    Thanks again for providing the code.

  • Posted 8 September 2017, 11:52 am EST

    I also found this page that seems to talk about adding the autopostback property to controls. Might this be an alternative? Please let me know. It seems to be for individual cells, not columns, though. I’m just not sure.

    http://sphelp.grapecity.com/WebHelp/SpreadNet10/ASP2/FarPoint.Web.Spread~FarPoint.Web.Spread.IAutoPostBack~AutoPostBack.html

  • Posted 8 September 2017, 11:52 am EST

    Hi Karen,

    The above alternative will work for cells which has ComboBox Celltype or any other celltype .

    The code given by me will work for all cells.

    Thanks,

    Deepak Sharma

  • Posted 18 October 2017, 6:50 am EST

    I’d like to use this technique, but I can’t quite decipher the code. Here’s the code from the link above . . .

    FarPoint.Web.Spread.ComboBoxCellType cb = new FarPoint.Web.Spread.ComboBoxCellType(new string[] {"One", "Two", "Three"});
    cb.ShowButton = true;
    FpSpread1.ActiveSheetView.Cells[0, 0].CellType = cb;
    FpSpread1.EnableClientScript = false;
    
    private void FpSpread1EditCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) 
    {
        bool ap;
        FarPoint.Web.Spread.Editor.IEditor ed;
        ed = e.SheetView.Cells[e.CommandArgument, 0].Editor;
        if (fpEditor is FarPoint.Web.Spread.IAutoPostBack) 
        {
            ap = ((FarPoint.Web.Spread.IAutoPostBack) ed).AutoPostBack; 
            Response.Write(ap.ToString()); 
        }
    }
    

    For this purpose, please assume a combobox called “cbo_Employees”. it will be a multicolumcombobox, and I know regular comboboxes already have a postback setting, but I can probably adapt this for what I need. Also, it’s the whole column that needs to be set, not an individual cell, and I’m not sure how to do that below . . .

    Assume the combobox column is column 1 (not column 0).

    Is what I have below correct? Please let me know

    FarPoint.Web.Spread.ComboBoxCellType cbo_Employees = new FarPoint.Web.Spread.ComboBoxCellType(new string[] {"One", "Two", "Three"});
    cb.ShowButton = true;
    FpSpread1.Sheets[0].Columns[1].CellType = cbo_Employees;
    FpSpread1.EnableClientScript = false;
    
    private void FpSpread1EditCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) 
    {
        bool ap;
        FarPoint.Web.Spread.Editor.IEditor ed;
        ed = e.SheetView.Cells[e.CommandArgument, 1].Editor;
        if (fpEditor is FarPoint.Web.Spread.IAutoPostBack) 
        {
            ap = ((FarPoint.Web.Spread.IAutoPostBack) ed).AutoPostBack; 
            Response.Write(ap.ToString()); 
        }
    }
    

    I have the feeling that this isn’t setting autopostback for the combobox in this entire column. Any suggestions?

  • Posted 27 October 2017, 6:11 pm EST

    Hello,

    The above code will work for ComboBoxCellType but not for MultiColumnComboBoxCellType because MultiColumnComboBoxCellType does not implement IAutoPostback interface while ComboBoxCellType does.

    The approach suggested by me in my first post on this thread, can help you to know when there is a DataChange at client side.

    Thanks,

    Deepak Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels