EditMode issues

Posted by: seshareddy.kamaganiguntla on 19 April 2022, 8:52 am EST

  • Posted 19 April 2022, 8:52 am EST - Updated 3 October 2022, 9:18 am EST

    Hii ,

    I need support on following things related to EditMode.

    i) How can we change border during editMode of a cell.

    ii) How to close Editor opened on a cell , without entering any value programatically? (using sheet.startEdit() method to open an editor on an active cell , i need opposite of it).

    iii) On Entering value , i need to display formatted value on sheet (like add decimal places etc.,) instead of user entered value directly.

  • Posted 20 April 2022, 12:07 pm EST

    Hi Sesha,

    1. The default blue color around the cell is nothing but the border which is applied to the editor element(when the cell is in edit mode). To change the border, you should change the border of the editor element. You can override the createEditorElement method(that creates a dom for the editor element) and add a className to the editorElement so that it can be customized easily thought css classes.
        let oldCreateEditorElementFn = GC.Spread.Sheets.CellTypes.Text.prototype.createEditorElement;
        GC.Spread.Sheets.CellTypes.Text.prototype.createEditorElement = function (context, host) {
            host.classList.add('gcEditorElementOuterDiv');
            return oldCreateEditorElementFn.apply(this, arguments)
        }
    

    createEditorElement method: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Sheets.CellTypes.Base~createEditorElement.html

    You can refer to the attached sample for the same. Note: I have added the gcEditorElementOuterDiv css class in the index.html file of the sample.

    1. You can use the endEdit method that stops the editing of the active cell.

    endEdit method: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Sheets.Worksheet~endEdit.html

    1. For your use case, you should override the setEditorValue function and returns the formatted data. You can get the formatted data by using getText() method.
    
        let oldSetEditorValueFn = GC.Spread.Sheets.CellTypes.Text.prototype.setEditorValue;
        GC.Spread.Sheets.CellTypes.Text.prototype.setEditorValue = function(editorContext, value, context) {
            let row = sheet.getActiveRowIndex();
            let col = sheet.getActiveColumnIndex();
            if(!sheet.getFormula(row, col)) {
                value = sheet.getText(row, col);
            }
            return oldSetEditorValueFn.apply(this, [editorContext, value, context]);
        }
    

    setEditorValue method: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Sheets.CellTypes.Base~setEditorValue.html

    getText method: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Sheets.Worksheet~getText.html

    Sample: https://jscodemine.grapecity.com/share/tFdqbTjgv0mmZRDUWpQNLg/

    Please let us know if you require further assistance with your query? We will be happy to help you.

    Regards

    Ankit

  • Posted 29 April 2022, 8:36 am EST - Updated 3 October 2022, 9:18 am EST

    Hii ,

    Overriding Cell Border is working fine , but a colored dot is appearing on the screen after adding that style (as posted in screenshot) . Could you please let us know , how to remove that.

  • Posted 2 May 2022, 12:06 am EST

    Hi Sesha,

    You just need to add a css attribute selector for absolute style position.

    		div.gcEditorElementOuterDiv[style*="position: absolute;"]{
    			border: 2px solid red !important;
    		}
    

    For example, you can refer to the following sample that I have created for you: https://jscodemine.grapecity.com/share/3HozononDEKbFjdghKtvwA/

    Please let us know if you require further assistance with your query? We will be happy to help you.

    Regards

    Ankit

Need extra support?

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

Learn More

Forum Channels