Jump to content

Recommended Posts

Posted

Do you mean selecting a continuous range of cells (like in Excel), or selecting individual cells separately using Ctrl+Click?

Posted
19 minutes ago, Alr1976 said:

Any News?

Hello,
I understand your interest in getting a quick solution, and we all try to help each other here as much as possible. However, please keep in mind that not all questions get an instant or complete answer on the forum. Sometimes it takes time and effort to find or test a working solution.

For your first scenario (selecting a range of cells), I recommend checking this post:

You can analyze how to get the selected cells, but you will need to do some additional research and adjustments to fully implement the required logic.

For the second scenario (selecting arbitrary cells), you can analyze the cellclick event, and try to add/remove a custom selection class on click. Later, you can collect all selected cells by their class name.
These are just some hints to point you in the right direction.

Hope this helps a bit.

  • 2 weeks later...
Posted

Hello, 

1 hour ago, Alr1976 said:

Ok now i can select multiple cells. How can know which cells are selected?

 

On 7/15/2025 at 3:23 PM, Sherzod said:

...but you will need to do some additional research and adjustments to fully implement the required logic.

 

Posted

ok, I need to know RangeSelection. How to implement it?

i tried:

function selectionchange(model, selected, eOpts) {
  // 'model' è il SelectionModel. La griglia è accessibile tramite la sua view.
  // Questo è il metodo più affidabile per ottenere il riferimento alla griglia.
  var grid = model.view.ownerGrid;

  // Se 'grid' fosse ancora undefined, un'alternativa è usare il parametro 'selected'.
  // L'oggetto 'selected' (Ext.grid.selection.Cells) ha un riferimento al suo selModel.
  if (!grid && selected && selected.view) {
      grid = selected.view.ownerGrid;
  }

  // Se dopo entrambi i tentativi la griglia non è definita, usciamo per sicurezza.
  if (!grid) {
      console.error('uniGUI Error: Could not get a reference to the grid.');
      return;
  }

  // Controlliamo che 'selected' sia un oggetto di selezione celle valido.
  if (!selected || !selected.isCells) {
    ajaxRequest(grid, 'cellSelection', ['[]']);
    return;
  }

  var cells = selected.getCells();
  var selectedData = [];
  var store = grid.getStore();
  var columns = grid.getColumns();

  for (var i = 0; i < cells.length; i++) {
    var cellCoord = cells[i];
    var rowIndex = cellCoord[0];
    var colIndex = cellCoord[1];
    
    if (rowIndex < store.getCount() && colIndex < columns.length) {
      var record = store.getAt(rowIndex);
      var fieldName = columns[colIndex].getDataIndex();
      var cellValue = record.get(fieldName);

      selectedData.push({
        row: rowIndex,
        col: colIndex,
        value: cellValue
      });
    }
  }

  var jsonData = Ext.JSON.encode(selectedData);
  ajaxRequest(grid, 'cellSelection', [jsonData]);
}

 

But doesn' t works

tks,Alessandro

 

  • 3 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...