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

[Solved] (batch mode) add new record w/ default dropdown

2 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
adam
Top achievements
Rank 1
adam asked on 05 Aug 2013, 05:56 PM
When a new record is added in the demo link below, the dropdown does not always initialize at index 0.  It will remember the index of a previous selected row's dropdown.  How can it be made to always initialize at 0 when a new record is added? 

http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/batchediting/defaultcs.aspx

2 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 08 Aug 2013, 02:42 PM
Hi Adam,

Indeed your observations are correct. The behavior is due to the fact that only one editor is initialized for the entire column(this is done for optimization purposes). If however defaulting the dropdown is a requirement you can subscribe to the OnBatchEditSetEditorValue and manually select the first item in the RadDropDownList. If we refer to the online demo example the mentioned can be achieved with the help of this JavaScript:
function SetEditorValue(sender,args) {
            if (args.get_columnUniqueName() === "CategoryID") {
                var container = args.get_container();
                $telerik.findControl(container, "CategoryIDDropDown").getItem(0).set_selected(true);
            }
        }


Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
adam
Top achievements
Rank 1
answered on 15 Aug 2013, 07:04 PM
Hi Angel,

That javascript worked for me as well.

Thanks,
Adam
Tags
Grid
Asked by
adam
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
adam
Top achievements
Rank 1
Share this question
or