Batch Add: need all fields editable

Hi ,

We are trying to implement batch add for the grid and not edit mode, so we need all the fields to be editable when user click on add button , and once he fills all the fileds, he can add new row, How can we achieve this?

Thanks,
Dileep gagan R

5 Replies

VS Vignesh Sivagnanam Syncfusion Team September 16, 2020 01:19 PM UTC

Hi Dileep 

Thanks for contacting Syncfusion support. 

Based on your update we are unclear about your exact requirement, so please share the following details it will help us to provide better solution, 

1. You have mentioned that you need all the fields to be editable when user click on add button. So, please confirm are you mentioning the toolbar button or external button? 

2. Share the screenshot or video demonstration of your requirement. 

3. Share the complete grid rendering code. 

4. Syncfusion Package Version. 

Regards, 
Vignesh Sivagnanam 



DG Dileep gagan R September 17, 2020 08:07 AM UTC

Hi, 

Below is the screenshot of the grid, here we have validation of each fields and we do not want to add next row unless all fields are entered.



We cannot use normal Add as, we are using inbuilt update to bulk update. Kindly guide us How to achieve both country and editable when add button is clicked and do not allow user to add next row unless all fields are filled.


VS Vignesh Sivagnanam Syncfusion Team September 18, 2020 01:52 PM UTC

Hi Dileep 

Thanks for your update. 

Based on your query you need to avoid the new row added until all fields are filled. To achieve your requirement we suggest you to use the column validation in columns API.    

Please refer the documentation and Sample for your reference  



Please let us know, if you need further assistance. 

Regards, 
Vignesh Sivagnanam 



DG Dileep gagan R September 21, 2020 06:24 AM UTC

Hi,

Thanks for the update, but in our case we are having mutual exclusion dropdown which are dynamically created for dynamic columns, So to enable and bind the data to the child dropdowns , we need fields to be enabled , and in of the column we have two textboxs which only one text box is mandatory so, basic required for all fields will not suffice our requirement. Below is the code for dynamic dropdowns and initialization of grid and creation of dynamic columns.

 this.initGrid(res.data.columns.map((eli=> {
          const prop = el.replace(/\s/g'');
          this.renderedColumns = res.data.columns;
          return {
            field: prop + 'Code'headerText: this.titleCasePipe.transform(el),
            valueAccessor: (fieldstringdataObjectcolumnColumn=> {
              return (data[prop + 'Code'] && data[prop + 'Code'] !== '') && (data[prop] && data[prop] !== '') ?
                data[prop + 'Code'] + ' | ' + data[prop] : data[prop] || data[prop + 'Code']
            },
            editType: (i === (res.data.columns.length - 1) ? '' : 'dropdownedit'),
            edit: i === (res.data.columns.length - 1) ? '' : this.editRow(iel),
            editTemplate: i === (res.data.columns.length - 1) ? this.textBox : '',
            validationRules: i === (res.data.columns.length - 1) ? '' : { required: true },
            autoFit: true
          }
        }));


  private initGrid(col?) {
    this.columns = [{ type: 'checkbox'width: 10 }];
    this.columns = col ? (this.columns as any).concat(col) : [];
    // this.filterOptions = { type: 'Excel' };
    this.toolbarOptions = ['Add''Update''Delete''Cancel''Search'];
    this.editSettings = {
      allowAdding: trueallowDeleting: truemode: 'Normal'//allowEditing: true,
      showDeleteConfirmDialog: trueshowConfirmDialog: true
    };
    this.pageSettings = { pageSizes: truepageSize: 5 };
    this.sortOptions = col ? { columns: col.map(el => { return { field: el.fielddirection: 'Ascending' } }) } : {};
    this.windowHeight = window.innerHeight !== undefined ? window.innerHeight - 350 : 400;
    if (this.grid) {
      this.grid.clearFiltering();
      this.grid.refresh();
      console.log(this.grid.columns);

    }
  }

  private editRow(idxctrl) {
    let dropDownListEditIEditCell;
    let dropDownListDropDownList;
    let eleHTMLElement;

    dropDownListEdit = {
      create: () => {
        ele = document.createElement('input');
        return ele;
      },
      read: () => {
        return dropDownList.text;
      },
      destroy: () => {
        dropDownList.destroy();
      },
      write: (args: { rowDataobjectcolumnColumn }) => {

        dropDownList = new DropDownList({
          dataSource: idx === 0 ? this.parentDdlData : [],
          allowFiltering: true,
          fields: { value: 'id'text: 'name' },
          itemTemplate: "<div>${name} | ${description}</div>",
          change: () => {
            let tempQueryQuery = new Query().where('id''equal'dropDownList.value);
            this.editDropDowns.forEach((eli=> {
              if (!(i <= idx)) {
                el.text = nullel.enabled = false;
                this.disabled = true;
                this.location.name = null;
                this.location.description = null;
              }
            });
            if (tempQuery.queries[0].e.value != null) {
              this.getGridDropdownData(tempQuery.queries[0].e.value).pipe(takeUntil(this.unSubscribe)).subscribe(res => {
                this.validationData = res.data;
                if (this.editDropDowns[idx + 1]) {
                  this.editDropDowns[idx + 1].enabled = true;
                  this.editDropDowns[idx + 1].text = null;
                  this.editDropDowns[idx + 1].dataSource = res.data;
                  this.editDropDowns[idx + 1].dataBind();
                } else {
                  this.disabled = false;
                }
              });
            }
          },
          filtering: (e=> {
            const data = dropDownList.dataSource
            let predicate = new Predicate('description''startswith'e.texttrue);
            predicate = predicate.or('name''startswith'e.texttrue);
            let queryQuery = new Query();
            //frame the query based on search string with filter type.
            query = (e.text !== '') ? query.where(predicate) : query;
            //pass the filter data source, filter query to updateData method.
            e.updateData(dataquery);
          },
          actionComplete: () => false,
          enabled: idx !== 0 ? false : true,
          placeholder: 'Select ' + ctrl,
          floatLabelType: 'Never'
        });
        dropDownList.appendTo(ele);
        this.editDropDowns.push(dropDownList);
      }
    }
    return dropDownListEdit;
  }



Thanks,
Dileep gagan R


VS Vignesh Sivagnanam Syncfusion Team September 22, 2020 01:39 PM UTC

Hi Dileep,  
   
Thanks for your update.  
   
Incident has been created to fulfill your requirements. So please follow up on the incident for further updates.  
   
Regards,  
Vignesh Sivagnanam 


Loader.
Up arrow icon