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

Dropdownlist returns string even if value was type string.

I have a following grid:

<ej-grid id="Grid" [dataSource]="syncJobs" [allowSorting]="true" (cellEdit)="save($event)" (cellSave)="saveRecord($event)" [allowScrolling]="true"
            [editSettings]="{'allowEditing':'false', 'editMode':'batch', 'showConfirmDialog':false}">
            <e-columns>
                <e-column field="activityTypeID" foreignKeyField="value" foreignKeyValue="text" [editParams]="{'showPopupOnLoad': true, 'popupHeight':'252px'}" [dataSource]="activityTypesList" headerTextAlign="center" headerText="Деятельность"></e-column>
            </e-columns>
</ej-grid>

The activityTypeID field holds an int value. I want to edit this field with dropdown, and for that i've created a datasource "activityTypesList" of text-id pairs. The id, obviously, match the activityTypeID, and the text holds the label for the id. I want that label to be shown in the field, so I've used foreign key property for the field.


The problem I've met is, that even though both grid and dropdown hold int values within itself, when you pick something from the list, the field value becomes string. I have to events to check that — cellEdit, that triggers as soon as editing starts, and that shows me the original field value, and the cellSave, that happens right after the editing had finished, and shows me the edited value. cellEdit rowData shows activityTypeID value being int. cellSave — string. I would prefer, so that the original type would prevail.

I would also prefer not to complicate the grid with editTemplate, if this is possible. 

Please advise.



1 Reply

RA Rykunov Alex February 13, 2017 12:34 PM UTC

Moreso, as I can see, even though the rowData value is just a string, the 'value' that comes with the cellSave event is worse, as it changes itself to the whole dropdownlist object. As an example, the original field value would be 4, the rowData value after editing would be "4", and the event value would be Object: {text: "ExampleActivityType, value: "4"}. It makes it hard to compare "value" and "previousValue", making them essentialy useless. Is this a bug or an intended behaviour?

I would appreciate help on the question.

Loader.
Up arrow icon