cellClickHandler doubt

1 Answer 198 Views
ComboBox Grid
alexis
Top achievements
Rank 1
alexis asked on 30 Mar 2022, 05:13 PM

Hello, I have the following scenario:

The column status is represented in the following code:

   <kendo-grid-column  [headerStyle]="{'font-weight': 'bold'}" [width]="200" field="status" title="Status">
        <ng-template kendoGridCellTemplate let-dataItem>
            <span class="whole-cell" [style.backgroundColor]="colorCode(dataItem.status.description)">
                <kendo-combobox [data]="statuses" textField="description" valueField="code" [filterable]="true"
                    (filterChange)="handleFilter($event)" [(ngModel)]="dataItem.status">
                </kendo-combobox>
            </span>
        </ng-template>
    </kendo-grid-column>

 

 

When I click in the blue part, the grid run the following code:

 public cellClickHandler({ sender, rowIndex, columnIndex, dataItem, isEdited }) {
    if (!isEdited) {
      sender.editCell(rowIndex, columnIndex, this.createFormGroup(dataItem));
    }

 

 public createFormGroup(dataItem: any): FormGroup {
    return this.formBuilder.group({
      orderNumber: dataItem.orderNumber,
      status: [dataItem.status, Validators.required],
      customerDateWanted: dataItem.customerDateWanted,
      providerShipDate: dataItem.providerShipDate,
      boxesCount: dataItem.boxesCount,
      providerCode: dataItem.providerCode,
      brand: dataItem.brand,
      postharvest: dataItem.postharvest,
      boxType: dataItem.boxType,
      bunchesUnitPerBox: dataItem.bunchesUnitPerBox,
      flowerCost: dataItem.flowerCost,
      observation: dataItem.observation,
      slots: dataItem.slots,
      flowerCode: dataItem.flowerCode,
      flowerGrade: dataItem.flowerGrade,
      composition: dataItem.composition,
      pricesB: dataItem.pricesB
    });
  }

I have a doubt about the isEdited field because always is false, when is true?

In the next link you can see the problem with the component:

https://www.loom.com/share/8bf170aefde14cafa44e6250ab6d7b76

 

dataItem.status is an object like {value:1, description:"PROCESS"}

 

Which is my problem ?

 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 04 Apr 2022, 09:23 AM

Hi Alexis,

Thank you for the provided details and video.

The isEdited field shows if the current cell is currently in edit mode or not. In order to see that the click should be performed within the cell, but outside the current input element used for editing. 

http://somup.com/c3ffQlO1PA

About the second part of this thread, the kendoGridEditTemplate should be added to the Grid column. Basically, the kendoGridEditTemplate should be used when it is required to customize the content of any cell that is being currently edited:

https://www.telerik.com/kendo-angular-ui/components/grid/columns/templates/#toc-edit-template

At the same time, the kendoGridCellTemplate shouldn't be removed, but its content could be changed in order to demonstrate the selected value. In general, the kendoGridCellTemplate is used to customize the content of a cell which displays some data when the cell isn't in edit mode:

https://www.telerik.com/kendo-angular-ui/components/grid/columns/templates/#toc-cell-template

I hope these suggestions help. Please let me know if any further information is required on this case.

Regards,
Svet
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ComboBox Grid
Asked by
alexis
Top achievements
Rank 1
Answers by
Svet
Telerik team
Share this question
or