Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
485
Simple select pair (value, text ) on column grid
posted

HI:

I can't implement a simple selection with igx-select control on grid  column that returns the key value  (numeric) with a selection of text .

like data = {id:1, city:'buenos aires'},{ id:2, city: 'la plata', ....}

can you help me?

Pablo

Parents
No Data
Reply
  • 1560
    Offline posted

    Hello,

    I have been looking into your question and created a sample application in order to demonstrate how such behavior could be achieved. As you can notice in the attached sample, I have retemplated the igxCell of the City column in order to add an igxSelect with described structure:

    <igx-column field="City" header="City" [dataType]="'string'" width="25%" [editable]="true" [resizable]="true">
                                  <ng-template igxCell let-cell="cell">
                                                 <igx-select [(ngModel)]="cell.value" #select 
           style="width:100">     
                                                                <igx-select-item *ngFor="let item of selectData" [value]="item.city" >
                                                                               {{item.id}}: {{item.city}}
                                                                </igx-select-item>
                                                 </igx-select>
                                  </ng-template>
                   </igx-column>

    Here you can find my sample for your reference.

    However, please keep in mind that the grid data in the City column contains only the city's name and in case of sorting, for example, the values of this column would be sorted depending on the city (not the id).

    Additionally, if you need a select only when editing a cell in this column you could retemlate the igxCellEditor instead of IgxCell.

    Let me know if I may be of any further assistance.

    Sincerely,

    Teodosia Hristodorova

    Associate Software Developer

Children