Using array index as value

Hi Team

On multiselectdropwn component we use 

text and value properties to specify what to display and what is the value of the select box

we would like to use index of array as value as that is our primary identifier

Currently we are using

public mycheckFields: Object = { text: "dosTo", value: 'dosTo'};


and we would like to use

public mycheckFields: Object = { text: "dosTo", value: 'id' };

OR

public mycheckFields: Object = { text: "dosTo"};


where value of dropdown selection is index of array

https://stackblitz.com/edit/angular-pzfdz8?file=app.component.ts


Thanks
Mohit


3 Replies

BC Berly Christopher Syncfusion Team January 14, 2022 10:45 AM UTC

Hi Mohit, 

As per your requirement, you can add additional field in the datasource as id to specify it as number and map the id field with value in mycheckFields. So, while select an item in the popup, you will get the id in the event.itemData argument. 

// map the groupBy field with category column 
public mycheckFields: Object = { text: 'dosTo', value: 'id' }; 
 
public myc = [ 
  { 
    dosFrom: '03/21/2021', 
    dosTo: '03/21/2021', 
    id: 1, 
    provider: 'Hughes, Patricia - 1012345678', 
    pos: '11 - Office', 
    noteType: 'Progress / Consult Note', 
    diagnosisDetail: [ 
      ...] 
    }, 
    { 
      dosFrom: '07/05/2021', 
      dosTo: '07/05/2021', 
      id: 2, 
      provider: 'Hughes, Patricia - 1012345678', 
      pos: '11 - Office', 
      noteType: 'Progress / Consult Note', 
      diagnosisDetail: [ 
        ...] 
      }, 
      { 
        dosFrom: '08/08/2021', 
        dosTo: '08/08/2021', 
        id: 3, 
        provider: 'Hughes, Patricia - 1012345678', 
        pos: '11 - Office', 
        noteType: 'Progress / Consult Note', 
        diagnosisDetail: [ 
          ...] 
      } 

 

  

  
Kindly check with the above suggestion meets your requirement.  
  
Regards, 
Berly B.C 



RM Raj Maheshwari replied to Berly Christopher January 14, 2022 06:06 PM UTC

Hello Berly 

Thank you for your reply on this


As this require modification on every single object that we plan to use with grid, and it requires to go through thousands of objects and inject new fields in various models that we have.

is it possible ot use the *index of array* as the identifier


Thank you
Mohit

 



VJ Vinitha Jeyakumar Syncfusion Team January 17, 2022 01:56 PM UTC

Hi Mohit,


We want to let you know that we didn't have support for the 'index' property in Multi select Dropdown control. If you want to use the Index property to set or get the index value of the selected items in the component, you can use our Dropdown List control.


You can also dynamically add the array index value to achieve your requirement, please check the reference link below,


Regards,
Vinitha



Loader.
Up arrow icon