revolist / revogrid

Powerful virtual data grid smartsheet with advanced customization. Best features from excel plus incredible performance 🔋
https://rv-grid.com
MIT License
2.79k stars 175 forks source link

How to make cells non editable? #248

Closed chneqiang closed 3 years ago

chneqiang commented 3 years ago

I want to control that some cells are not editable

Super-Chama commented 3 years ago

@van-huyen for copy/pase behaviour use beforeautofill or use readonly mode

van-huyen commented 3 years ago

Oh thank @Super-Chama ,

if use readonly mode, we can not control disable/enable input for each cell like this question. i tried used beforeautofill but it not handle behavior Ctrl + V. i'm still finding what is the event of Ctrl + V on Revo-Grid 😃 so i'm disabling clipboard func. image

Regards!

franz-josef-kaiser commented 3 years ago

You can use the readonly flag. It's an attribute (use on VueComponent <revo-grid readonly="true"> for all cells), as well as a property (use on data source for selected cells only).

Jyoti-Khatkar commented 1 year ago

@franz-josef-kaiser @Super-Chama @revolist is it possible to make a single column editable and others will be only in readOnly mode, till now i just use readOnly but it makes the whole table readOnly mode, but i want a type of attribute that works as per column.

jorge-koki commented 1 year ago

Lo que ise para poder realizar esto, es agregar una propiedad llamado editable, despues en el componente ejecute el evento @beforeeditstart y luego recorro el arreglo de cuales tiene editable, y a esas le agrego e.preventDefault();

Columns

{
    prop: "delete",
    name: "",
    size: 80,
    cellTemplate: VGridVueTemplate(BtnDeleteComp),
    editable: false,
  },

Template

   <VGrid
          ref="VGridRef"
          theme="material"
          style="height: 100%"
          :source="tableData"
          :columns="columns"
          :auto-size-column="false"
          :resize="true"
          :exporting="true"
          :readonly="false"
          @beforeeditstart="beforeEditStart"
        ></VGrid>

Function

function beforeEditStart(e) {
  let propsNoEditable = [];

  for (let index = 0; index < columns.length; index++) {
    if (
      columns[index].editable !== undefined &&
      columns[index].editable === false
    ) {
      propsNoEditable.push(columns[index].prop);
    }
  }

  if (propsNoEditable.includes(e.detail.prop)) {
    e.preventDefault();
  }
}

Esto lo realize por q no me gustaba que se viera opaco la imagen que tenia al ponerle readonly