We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

editTemplate selectedItemIndex

I have the following grid:

[editTemplate]="{create:dropCreate, read:dropRead, write:replacedDropWrite}">

[editTemplate]="{create:dropCreate, read:dropRead, write:userDropWrite}">>

[editTemplate]="{create:dropCreate, read:dropRead, write:projectDropWrite}">>

I need the editTemplate because I need to slightly customise my dropdown — to add filterSearch in it. Here's one of the editTemplate 'write' methods:
args.element.ejDropDownList({enableFilterSearch:"true", width: "100%", dataSource: args.column[1].dataSource, fields: { text: "value", value: "value" }, selectedItemIndex:args.rowData != undefined ? args.rowData["userId"] : 0 });
The whole problem I have is with selectedItemIndex property. Logically, I want dropdown to have the exact value to be selected, that was selected before. So, if I have a value of 2 in the unedited record, i want "2" to be the dropdown's selected value too. However, that seems not to be possible.
The "rowData" property of the args I could've used to select a proper value, comes undefined always. There's no other properties in the args that could've been used to get the required data. I am not willing to use Jquery in this project to solve the problem that way. So, answer any question of the following:
Why the rowData comes undefined? Is there a way to fix it?
Is there a way to select the value needed without setting the selectedItemIndex?
Or, if editTemplate does not work as intended, is there a way to customise a dropdown that is created by default, without editTemplate?
I will await your answer.

2 Replies

RA Rykunov Alex February 6, 2017 09:13 AM UTC

A solution is simple. It seems the online documentation does not describe "editParams" property in the right way. EditParams works for every in-cell editor, and not just numeric textbox. As an example, my solution works perfectly:

 <e-column field="replacedUserId" [editType]="Dropdown" [editParams]="{'showPopupOnLoad':true, 'enableFilterSearch':'true'}" foreignKeyField="value" foreignKeyValue="text" [dataSource]="users" headerText="User" >

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team February 7, 2017 11:57 AM UTC

Hi Alex,  
Thanks for the update. We have also explained about the functionality of the EditParams in the following Help Document. 
This document explains the params that were applicable for some of the ej controls. In the following API doc, we have shown the reference for editParams with a single control but it can also be used for multiple controls as explained in the above Help Document. 
We are also happy to hear that you have figured out the solution and you are good to go. Please get back to us, if you require further assistance on this. 
Seeni Sakthi Kumar S. 

Live Chat Icon For mobile
Up arrow icon