Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1460
startEditTriggers do not work if grid also has Selection
posted

If the grid has Selection and Updating, setting the startEditTriggers doesn't work.  Only double-clicking will work to initiate edit mode.  Click or F2 will not.

 

 

grid.igGrid(
                { columns: buildColumns(),
                    features: [
                        {
                            name: "Sorting",
                            type: "local"
                        },
                        { name: "Selection",
                            mode: "cell",
                            multipleSelection: false,
                            activation: true,
                            cellSelectionChanged: function (evt, ui) {
                                var actualRowIdx = ui.cell.row[0].rowIndex - 1 // rowIndex is not zero based (and varies both on naming standard and zero-base depending on which event is being used [good times indeed]), but methods expect a zero-based index 
                                if (ui.cell.columnKey === 'NextRound') {
                                    var myCell = grid.igGridSelection('getCellValue', actualRowIdx, 'NextRound');
                                    var dataview = grid.data('igGrid').dataSource.dataView();
                                    var myVal = dataview[actualRowIdx]["NextRound"];

				    grid.igGridUpdating("setCellValue", actualRowIdx, 'NextRound', !(myVal));
                                    dataview[actualRowIdx]["NextRound"] = !(myVal);

                                    grid.igGridSelection('deselectCell', actualRowIdx, ui.cell.index);
                                    grid.igGridUpdating('endEdit');

                                    grid.igGridSelection("clearSelection");
                                }
                                else {
                                    // grid.igGridSelection('selectCell', actualRowIdx, ui.cell.index );
                                    grid.igGridUpdating('startEdit', actualRowIdx, ui.cell.index);
                                }

                            }
                        },
                        { name: 'Updating',
                            editMode: 'cell',
                            enableAddRow: false,
                            enableDeleteRow: false,
                            validation: true,
                            startEditTriggers: 'click,dblclick,enter',                             editCellEnded: function (evt, ui) {

//NOTE: editCellEnded likes attention, it also likes to fire when entering edit mode on a cell }, editCellEnding: function (evt, ui) { //TODO: check valid value (number, not used previously, not more than # of competitors) & return false with alert if not ok if(ui.value!='' && isNaN(ui.value)){ alert('Not a valid scoring number'); //evt.stopPropagation(); evt.stopImmediatePropagation(); evt.preventDefault(); return false; //NOTE: see the mighty "editCellEnding" in action, its event propagation is unstoppable
                                }
                            }
                           
                        }],
                    width: "100%",
                    dataSource: CompetitionRound.RoundCompetitors,
                    autoGenerateColumns: false,
                    renderCheckboxes: true
                });

 

Parents
  • 845
    posted

    Hello again,

    In addition to my last solution, you can use one line of JavaScript code to enter edit mode with a single click. Here is the magic:

    cellClick: function(evt, ui) {
        $("#grid1").data("igGridUpdating").startEdit(ui.rowIndex, ui.colIndex, evt);
    },

Reply Children
No Data