function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KMK91KMK91 

Disable Data table check box in lwc and add Input number

Hi,

I can able to hide the checkbox in lwc data table , but how to add input number ?
Similar funtionality based on input number i have to add records
Any idea please ?

Thanks
KMK
HarshHarsh (Salesforce Developers) 
Hi KMK91,
  • As you mentioned you are able to hide the checkbox in the lwc data table.
  • Please try the below code and take a reference.
<template>
    <lightning-datatable
    key-field="id"
    columns={columns}
    data={lstRecords}
    >
</lightning-datatable>
</template>


---------------------------------
import { LightningElement,wire } from 'lwc';
import getRecords from '@salesforce/apex/fetchAccount.getRecords';
export default class ShowSeperateRowColumn extends LightningElement {
    columns = [{label : 'Row Number', fieldName : 'rowNumber',type : 'number'},
    {label : 'Name', fieldName : 'Name',type : 'text'},
    {label : 'Phone', fieldName : 'Phone',type : 'text'},
    {label : 'Type', fieldName : 'type',type : 'text'}];
    lstRecords;

    @wire (getRecords)fetchData(value) {
		const {
			data,
			error
		} = value;
		if (data) {
            let result = JSON.parse(JSON.stringify(data));
            console.log('result==> ' + JSON.stringify(result));
            

            for(var i=0; i<result.length; i++){
                result[i].rowNumber = i+1;
            }
this.lstRecords = result;
        }
        else if(error){
            console.log(error);
            this.lstRecords = [];
        }


    }
}
---------------------------------------------------

public with sharing class fetchAccount {
    
 @AuraEnabled(Cacheable=true)
    public static List<Account> getRecords(){
        return [SELECT Id,Name,Phone,type From Account];
       
    }
    
    
    
}

Please mark it as Best Answer if the above information was helpful.

Thanks.