This is a migrated thread and some comments may be shown as answers.

Multiple columns for a single field

6 Answers 617 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 27 Jul 2017, 11:50 AM
Hi,
I need a kendo grid with two columns for a single field, but with different editors:

                {
                    field: "VGNCode" // default text box editor
                },
                {
                    field: "VGNCode",
                    editor: codeDropDownEditor
                },

When i go into edit mode, both editors show up in both columns.
I expect the text box editor to show up in the first column and the dropdown list in the second column.

Is this a bug?
Is there a work-around?

I’m using Kendo UI v2016.3.1118 with AngularJS.

Thanks in advance!

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 31 Jul 2017, 08:40 AM
Hello Johan,

After testing the scenario, the columns have a different editor on my end even if they are bound to the same field:

http://dojo.telerik.com/oliyiT

As I can assume that there is a factor which we are overlooking at this moment, please send a fully runnable example and I will gladly assist.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Rebecca
Top achievements
Rank 1
answered on 25 Jan 2019, 09:07 PM
The difference comes in "incell" vs "inline" editable modes. In the posted demo, I've changed changed your grid to be "inline" editable, rather than "incell" editable, and added an "edit" command column, and am seeing the issue originally described. I'm having the same problem currently here.
0
Konstantin Dikov
Telerik team
answered on 29 Jan 2019, 12:31 PM
Hi Rebecca,

The two-way binding between the dataItem and the editor is achieved through the "data-bind" attribute and the "name" of the editors and with "inline" edit mode, rendering two editors for the same field will result in elements with identical "name" and "data-bind" attributes. I have to say that there is no built-in workaround that we could suggest for such requirement.

On a side note, could you please elaborate what is the reason behind displaying two different editors for the same field?


Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Rebecca
Top achievements
Rank 1
answered on 30 Jan 2019, 08:48 PM

I sure can. Thanks for asking.

The editor displayed in Column C differs depending on the value selected in Column B. As an example, say Column B is "method of verification" with options of "birthdate" or "department". When "birthdate" is selected, I want Column C to be a date picker. When "department" is selected, I want Column C to be a drop down list. It both cases, they are setting a generic "value" field on my Model. Additionally, when editing a new row, and no "method of verification" has yet been selected, I want no editor shown at all in Column C.

One of many ideas I had for solving this was to create multiple columns, showing and hiding appropriate columns based on the selected value. (That led me to the issue described in this thread.) Instead, I am now destroying and recreating inputs in the single editor when the value in Column B changes.

I see benefits and drawbacks to both solutions, though showing and hiding columns was actually cleaner in my code, had it worked as expected.

If there is another solution I've overlooked, I'd be happy to hear it. 

0
Konstantin Dikov
Telerik team
answered on 01 Feb 2019, 11:21 AM
Hello Rebecca,

Changing the editors dynamically in a single cell/column would be the recommended approach, because rendering multiple editors for the same field in multiple columns will not be possible. Another option would be to use "Batch/InCell" edit mode and initialize the editor for the C column based on the value of the other field:

Best Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Rebecca
Top achievements
Rank 1
answered on 01 Feb 2019, 01:24 PM
Unfortunately, inline vs incell edit mode provide very different user experiences, and our design calls for an inline editable row here. But thank you for the idea and clarification that the recommended approach is indeed dynamically changing the editor in a single column. Thanks!
Tags
Grid
Asked by
Johan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Rebecca
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or