Telerik Forums
Kendo UI for Angular Forum
0 answers
98 views

Hi,

there is this blog post about batch editing in the grid:

grid batch editing

I have two questions regarding it:

1. How to get a form field value?

Let's suppose, I want to get a value of a form field in the active row. For this I created a value change event and tested this:


<FormGroup[]>this.formArray.value)[rowIndex].controls

However, it returns undefined. So, no 'get' works too. But on the other side, if I log just this:


<FormGroup[]>this.formArray.value)[rowIndex]

I get the form fields.

2. How to set a form field value in the active row?

Thanks.

jan
Top achievements
Rank 1
Iron
 asked on 12 Dec 2021
0 answers
87 views

Hello,

I'm sorry for the strange request.

I am writing because I could not find a solution / idea.

I have to enable sorting with dedicated buttons for each column of the grid.

For example:

  • add 2 buttons in the header to manage the sorting (ascending / descending). 
  • add a combobox with the options ascending and descending sorting.

In attachment an example.

Could you please help me?
The project is in angular.

Francesco B.
Top achievements
Rank 1
 updated question on 10 Dec 2021
1 answer
1.1K+ views
I have a kendo grid with one column in the percentage format. Currently I am using the built in numeric filter with format = {0:p4} but when I enter 2 for example, the value is automatically multiplied by 100 and converted to 200.0000%. I don't want it to automatically multiply my input value by 100. How can I prevent that?
Hetali
Telerik team
 answered on 09 Dec 2021
2 answers
142 views
I have a Boolean grid column. If the value is true, I want to display 'Deleted', and if the value is false, I want to display 'Active'. What's the easiest way to do this, please?
Graham
Top achievements
Rank 2
Iron
Iron
 answered on 09 Dec 2021
1 answer
1.1K+ views

My client wanted to have input fields that were numeric (no text allowed). So after a long search and many experiments I managed to get it working. The Input field is a numeric textbox without spinners, in a grid

        <kendo-grid-column format="c1" [width]="100" field="jan" title="Jan {{ convertedYear }}" [editable]="editMode" [headerStyle]="currentMonth(0)">
          <ng-template
          kendoGridEditTemplate
          let-column="column"
          let-dataItem
          let-formGroup="formGroup">
          <kendo-numerictextbox [spinners]="false" [formControl]="formGroup.get(column.field)">
        </kendo-numerictextbox>
        </ng-template>
        </kendo-grid-column>

The problem is ... that values are shown as currency values, even when they are 0. For all numbers that would be fine, except for the 0, which they want to be a plain 0. example below

I tried changing the format="c1" ... but any changes there are not possible, and there is no way to know what value the field will hold in the column itself.

I tried changing the ng-template with [format]="formatOptions" and then setting them, but that changes the format in the numerictextbox field and not the column representation.

is there a way to conditionally format the column cell formatting on the condition being 0 ...

 

thank you for the help

Martin Bechev
Telerik team
 answered on 07 Dec 2021
1 answer
2.0K+ views

I'd like to pass a cell template to a grid column at runtime. The template is just a string that I have elsewhere in memory and can't be declared ahead of time.

I'm looking at the following example at: https://www.telerik.com/kendo-angular-ui/components/grid/columns/templates/#toc-cell-template

<kendo-grid [data]="gridData">
  <kendo-grid-column field="ProductName">
    <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
      Row: {{ rowIndex }} /
      <strong>{{ dataItem.ProductName }}</strong>
      <span class="{{ dataItem.Discontinued ? 'discontinued' : 'active' }}">
        {{ dataItem.Discontinued ? "discontinued" : "active" }}
      </span>
    </ng-template>
  </kendo-grid-column>
</kendo-grid>

What I want is for the entire ng-template to be defined elsewhere, or at least the contents of it. In the past I was able to do something like:

    <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
      {{ myTemplate }}
    </ng-template>

But this hasn't worked for a while. I suspect the custom template needs to be compiled somehow, but am not sure what to do. I looked in to using ngTemplateOutlet, but that also needs the template pre-declared. Any advice is appreciated. Thanks.

Svet
Telerik team
 answered on 07 Dec 2021
1 answer
529 views

I make this dynamic grid https://www.telerik.com/kendo-angular-ui/components/grid/columns/auto-generated/

this error appear :

Type 'string' is not assignable to type '"boolean" | "text" | "numeric" | "date"'.

<kendo-grid [kendoGridBinding]="collaborateurData" [filterable]="true" scrollable="none" [pageable]=true [pageSize]="10">
      <kendo-grid-column
        *ngFor="let column of columns"
        field="{{ column.field }}"
        title="{{ column.title }}"
        format="{{ column.format }}"
        filter="{{ column.type }}"
      ></kendo-grid-column>
</kendo-grid>

 

I also try this

but this error appear in my console :

Type '{ "": any; }' is not assignable to type 'CompositeFilterDescriptor'.

<kendo-grid [kendoGridBinding]="collaborateurData" [filterable]="true" scrollable="none" [pageable]=true [pageSize]="10">
  <kendo-grid-column
  *ngFor="let column of columns"
  field="{{ column.field }}"
  title="{{ column.title }}"
  format="{{ column.format }}"
>
<ng-template kendoGridFilterCellTemplate let-filter let-column="column">
  <!-- Modification du filtre par défault par son type -->
  <kendo-grid-string-filter-cell
  *ngFor="let column of columns"
    [showOperators]="false"
    [column]="column"
    [filter]="{{ column.type }}">
  </kendo-grid-string-filter-cell>
</ng-template>
</kendo-grid-column>
</kendo-grid>
Hetali
Telerik team
 answered on 06 Dec 2021
1 answer
570 views
Hi,
Can we pass kendo-grid map object? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
will the grid work with Map objects ?
Dimiter Topalov
Telerik team
 answered on 06 Dec 2021
1 answer
164 views

Noticed today, while using the toDataSourceRequestString method in @progress/kendo-data-query, that when passing in the SortDescriptor's, although dir? is an optional property, if you leave it null, the SortDescriptor will be excluded from processing and not included in the resultant string. We had to look really closely at the documentation of the property to see that it explicitly tells us that's the case, but seems odd that the dir? is set as optional. Just trying to understand the logic behind this decision... Why is the property optional, if its required?

 

(Ignore the tag, couldn't find an appropriate tag to use...)

Svet
Telerik team
 answered on 03 Dec 2021
1 answer
1.5K+ views

Given this HTML, how are grid components (e.g. kendo-dropdownlist) accessed and tested?

<form [formGroup]="computedFormGroup" style="box-sizing:border-box;padding:40px;">
<div style="width:100%">

<h1>Policy</h1>

<kendo-tabstrip ...>
<kendo-tabstrip-tab ...>
<ng-template kendoTabContent>

<kendo-grid ...>

<ng-template kendoGridToolbarTemplate>
<button mat-raised-button color="primary" kendoGridAddCommand>Add new</button>
</ng-template>

<kendo-grid-command-column title="Action" [sticky]="true" [width]="290">
<ng-template kendoGridCellTemplate let-isNew="isNew">
...
</ng-template>
</kendo-grid-command-column>

<kendo-grid-column field="aip" title="AIP" width="200" class="aip_ddl">
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.aip }}
</ng-template>
<ng-template kendoGridEditTemplate
let-dataItem="dataItem"
let-column="column"
let-formGroup="policyFormGroup">
<div class="aip_ddl">
<kendo-dropdownlist [defaultItem]="{ aipCode: null, aipCodeAndName: '' }"
[data]="aipModel"
[popupSettings]="{width:400}"
textField="aipCodeAndName"
valueField="aipCode"
class="aip_ddl"
[valuePrimitive]="true"
[formControl]="policyFormGroup.get('aip')">
</kendo-dropdownlist>
</div>
</ng-template>
</kendo-grid-column>

 

Unit test code:

it('should bind the configured value to the AIP dropdown list.', async(() =>
{
// Arrange
// Set the form group.
component.policyFormGroup = constPolicyFormGroup(data);
// Set the specific data to test.
component.policyFormGroup.controls.aip.setValue('FH');

I want to access and test the dropdownlist here:

                console.log(fixture.debugElement);
const element = fixture.debugElement.query(By.css('form'));
const attr = element.nativeElement.getAttribute('aip-ddl');
//expect(element.nativeElement.getAttribute('ng-reflect-resizable')).toBe('true');
//let select: HTMLSelectElement = fixture.debugElement.query(By.css('.aip_dll')).nativeElement;
//const myComponent = fixture.debugElement.query(By.directive(DashboardComponent));
//let select: HTMLSelectElement = fixture.debugElement.nativeElement.querySelectore('aip_dll');
let p = fixture.debugElement.nativeElement.querySelector('p');
fixture.detectChanges();
//component.aipModel..aip = new FormControl(component.policyFormGroup.controls.aip);
//fixture.detectChanges();
//fixture.whenStable().then(() =>
//{
// let text = select.options[select.selectedIndex].label;
// expect(text).toBe('Manager');
// expect(p.textContent).toBe('Manager');
//});
}));

Yanmario
Telerik team
 answered on 03 Dec 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?