How to enter defaul value in a newly Inserted row Please

Posted by: szilbermints on 1 October 2018, 6:43 am EST

    • Post Options:
    • Link

    Posted 1 October 2018, 6:43 am EST

    Hi

    1.I want to have some JavaScript event and line of js which would automatically set some default value in the very first column of sheet1 as soon as user clicks insert new row or add new row button please?

    2.Any way to build in “calendar” control in in all cells of certain column?

    3.What s the best way to validate numeric range for certain column?

    Also when l looked at your documentation I could not see certain js events listed such as “onmouseover” although they are mentioned in examples and seem to work fine. Where is list of all client side events please?

    Thank You

  • Posted 3 October 2018, 1:00 am EST

    Hello,

    1. For bound Spread control you can set the DefaultValue property of the bound DataColumn to the value you want to show when no other value is in that column. When you add a new row, this defaultValue will automatically show.

    Another option is that you catch the “InserCommand” event server side and set the default value using the code as below:

    FpSpread1.ActiveSheetView.AllowInsert = true; 
    protected void FpSpread1_InsertCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
    
        {
    
            e.EditValues[0] = "New Row";          
    
        }
    

    To do that in JavaScript you would need to use the CallBack(“Add”) method to raise the InserCommand event server side.

    1. You can set the celltype as DateCalendarCellType for whole column. This way all cells in that column and also newly added row will by default have Calendar celltype.

      http://help.grapecity.com/spread/SpreadNet11/ASP2/webframe.html#spweb-ajax-calendar.html

    For example:

    fpSpread1.ActiveSheetView.Columns[0].CellType= new DateCalendarCellType();
    
    1. You can set the celltype of the cells as IntegerCellType and can set the validation as per the proerties supported by that celltype. For example maximum value, minimum value validators etc.
    FarPoint.Web.Spread.IntegerCellType intcell = new FarPoint.Web.Spread.IntegerCellType();
    FpSpread1.ActiveSheetView.Cells[1, 1].CellType = intcell; 
    

    http://help.grapecity.com/spread/SpreadNet11/ASP2/webframe.html#FarPoint.Web.Spread~FarPoint.Web.Spread.BaseCellType~Validators.html

    Spread’s client side events are listed here:

    http://help.grapecity.com/spread/SpreadNet11/ASP2/webframe.html#clientscript-allevents.html

    You can catch the ‘onmousedown’ event for DOM element which is a DIV in case of Spread for ASP.NET.

    In case you have further questions, please feel free to get back to me.

    Thanks,

    Deepak Sharma

  • Posted 4 October 2018, 3:42 am EST

    Thank You Deepak,

    1.It appears that we using version of asp.net web spread control from 2012 and i can’t see calendar datatype, when i tried something like

    Dim ctCalend As New FarPoint.Web.Spread.Extender.DateCalendarCellType

    it crashes saying cannot load assembly

    so i wonder it was doable in that version

    1. Is there a way to load dropdown in certain column such as state list or like?

    3.Is there some link which states what’s new in diffrent versions of spread control, ours is from 2012 and if we’d like to upgrade

    Thank You

    S

  • Posted 4 October 2018, 9:23 pm EST

    Hello,

    1. You can simply set the celltype as DateTime celltype and see the calendar in edit mode. For example:
    FarPoint.Web.Spread.DateTimeCellType datecell = new FarPoint.Web.Spread.DateTimeCellType();
    datecell.ShowPopupButton = true;
    FpSpread1.ActiveSheetView.Columns[1].Width = 175;
    FpSpread1.ActiveSheetView.Cells[1,1].CellType = datecell;
    
    
    

    When you double click the cell to enter edit mode and then click or tap on the drop-down button to show the calendar. Select a date and then press the Enter key to finish editing the cell.

    1. You can use ComboboxCellType for the columns where you want to show a dropdown list. For example:
    
    string[] cbstr;
    cbstr = new String[] {"Jan", "Feb", "Mar", "Apr", "May", "Jun"};
    FarPoint.Web.Spread.ComboBoxCellType cmbbx = new FarPoint.Web.Spread.ComboBoxCellType(cbstr);
    FpSpread1.ActiveSheetView.Cells[1, 1].CellType = cmbbx;
    
    
    
    1. Certainly, you can find the release notes of all versions once you install the same. To know what’s new in the latest version version you can check following links:

      http://help.grapecity.com/spread/SpreadNET11ReadMe/webframe.html#rnotes.html

    Thanks,

    Deepak Sharma

  • Posted 5 October 2018, 4:51 am EST

    Thank You Deepak,

    We are using version 5.0.3524 of the control andwe use it as programmtically bound to dataset

    1. ShowPopupButton property does not seem to exist?

    2. Combobox loads ok but when i try to show original value which existed in the table row by using something like

    For jj As Integer = 0 To iRows - 1

                fpSpread1.Sheets(0).Cells(jj, 2).Value = myDS.Tables(0).Rows(jj).Item(2)
    
                'fpSpread1.Sheets(0).Cells(jj, 2).Text = myDS.Tables(0).Rows(jj).Item(2)
    
            Next
    

    it doesn’t work

    1. user can insert row ok into the control but cannot add new row again untill click “update” button. Is it normal?

    Thank You

    S

  • Posted 7 October 2018, 11:21 pm EST

    Hello,

    1. It looks this property was not available with v5, you would need to upgrade in order to use this.
    2. You would need to bind Combobox to Items of the table. The way you are setting the value in the cell, will be overridden always.
    3. This is correct, when you insert a row the row is inserted to the view but not update to the data model. Once you click the update button it raises a postback and the row is added to datamodel server side.

    Thanks,

    Deepak Sharma

  • Posted 9 October 2018, 4:37 am EST

    Thank You,

    How do i bind? You said “. You would need to bind Combobox to Items of the table. The way you are setting the value in the cell, will be overridden always.”

    I tried to bind and load combobox:

    Dim arrClients(1) As String

    arrClients(0) = “client1”

    arrClients(1) = “client2”

    ctCombo.Items = arrClients

    fpSpread1.DataBind()
        fpSpread1.Sheets(0).Columns(2).CellType = ctCombo
    

    or in reverse order but in any case it just loads combobox not value coming from Database

    also it looks when it tries to save to the database the dataset contains indexes 0 and 1 not values such as "client1’ and “client2”

    Thank You

    S

  • Posted 10 October 2018, 12:53 am EST

    Hello,

    You would need to update the value in cell/combo cell by clicking the “update” button on commandbar or calling the SaveChanges method server side.

    Thanks,

    Deepak Sharma

  • Posted 10 October 2018, 3:28 am EST

    Hi,

    I clicked and it does not resolve the issue

    I guess it has to be straightforward what i need to do.

    1.Load data from database and populate combobox in one of the columns with preselected(highlighted)

    values. But when it opens the view only very first value is shown “Client1”

    Dim arrClients(1) As String

    arrClients(0) = “fa”

    arrClients(1) = “wwp”

    ctCombo.Items = arrClients

    ctCombo.ShowButton = True

    'dataset created

    fpSpread1.DataBind()

        fpSpread1.Sheets(0).Columns(2).CellType = ctCombo
    
        For jj As Integer = 0 To iRows - 1
    
            fpSpread1.Sheets(0).Cells(jj, 2).Value = myDS.Tables(0).Rows(jj).Item(2)
    
                Next 
    
    1. When updating instead of writing back to the Database “Client1” or “Client2” ot writes indexes 0 or 1.

    Thank You

    S

  • Posted 11 October 2018, 1:51 am EST

    Hello,

    1. For this issue, you would need to set the cell value to one of the items from Combobox List after setting the combobox celltype.

      For example:
    
    
    FpSpread1.DataSource = workTable;
                    string[] cbstr;
                    cbstr = new String[] { "CustNumber1", "CustNumber2", "CustNumber3", "CustNumber", "May", "Jun" };
                    FarPoint.Web.Spread.ComboBoxCellType cmbbx = new FarPoint.Web.Spread.ComboBoxCellType(cbstr);
                    cmbbx.Items = cbstr;
                    cmbbx.ShowButton = true;
                    cmbbx.UseValue = true;
                    FpSpread1.ActiveSheetView.Columns[1].CellType = cmbbx;
                    FpSpread1.ActiveSheetView.Cells[0, 1].Value = "CustNumber3"; 
    
    1. For this, you may set the UseValue property of the ComboBoxCellType to true to enable using Value of the combobox selected item instead of the index. Please refer to the example I have shown above.

    Thanks,

    Deepak Sharma

  • Posted 11 October 2018, 7:53 am EST

    Thank You Deepak,

    This line: cmbbx.UseValue = true;

    fixed all the issues

    Thank You

    S

Need extra support?

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

Learn More

Forum Channels