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

Allow Insert but not Edit on a bound column in batch edit mode?

7 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
adam
Top achievements
Rank 1
adam asked on 28 Apr 2011, 04:15 PM
Hi Guys,
Anyone know how to do this?

Thanks,
Adam

7 Answers, 1 is accepted

Sort by
0
Craig Tarr
Top achievements
Rank 2
answered on 29 Apr 2011, 04:58 AM
Adam, are you talking about having a control, like a dropdown or autocomplete field in a batch edit column. And it only be visible/editable in an Insert situation. And in Edit it be readonly or displayed as a standard bound column?

0
adam
Top achievements
Rank 1
answered on 29 Apr 2011, 12:27 PM
Yes. Exactly.
0
Craig Tarr
Top achievements
Rank 2
answered on 29 Apr 2011, 01:28 PM
I'm actually working on that in my application today. I'll post back my work and see if it'll help.
0
Fethi
Top achievements
Rank 1
answered on 01 May 2011, 03:54 PM
Hi,
me too interested by your code.

Thank you in advance by sending your code.

Bye
0
Alejandro
Top achievements
Rank 1
answered on 27 May 2011, 05:11 AM
Hi, please reply here. I´m intrested on that same feature.

thanks
0
Craig Tarr
Top achievements
Rank 2
answered on 30 Jun 2011, 03:57 AM
All, sorry for the delay. I ended up going back and using the Grid in AJAX Editing mode. I have several requirements I need to complete and making the dropdownlist disabled on Edit mode isn't at the top.

In the AJAX Editing mode I just followed the Demo and set the Combobox or DropDownList to disabled on onEdit ClientEvent.

http://demos.telerik.com/aspnet-mvc/combobox/clientsideapi?theme=vista

When I finish up my remaining items I'll revisit the Batch Edit grid and post back my work.
0
Craig Tarr
Top achievements
Rank 2
answered on 18 Aug 2011, 04:36 PM
Let me know if this is what you were looking for.

In my Grid I have a Shared DropDownList control. On an Insert the DropDownList is populated and selectable. When in Edit mode the DropDownList is populated with only the selected value and the control is disabled.

The Grid has a ClientEvents OnEdit that looks like this:
function onEdit(e) {
var dataItem = e.dataItem;
var mode = e.mode;
var row = e.row;
var form = e.form;
var driverDropDownList = $(form).find('#Name');
var sponsorDropDownList = $(form).find('#Sponsor');
 
if (mode == 'insert') {
//we don't know who this is so we can't give them Sponsors
var sponsortest = $('#Sponsor').data('tComboBox');
                    if (sponsortest != undefined) {
                        sponsortest.fill(function () { sponsortest.select(function (item) { return item.Value == 2; }); });
                    }
                    else {
                        alert('undefined');
                    }
                    var dataSource = [
                        { Text: "Unsponsored", Value: "Unsponsored" }
                    ];
                     
                    $("#Sponsor").data("tComboBox").disable();
                }
 
 
                if (mode == 'edit') {
 
                    var grid = $('#EntryList').data('tGrid');
 
                    var combo = $('#Name').data('tDropDownList');
                    var value = combo.value();
 
                    var datasource = [{ Text: value, Value: value, Selected: true}];
                    combo.dataBind(datasource);
                    combo.value(value);
                    combo.text(value);
 
                    $("#Name").data("tDropDownList").disable(); //don't let em change the driver. Gotta delete and Insert i'm sorry!
                }
            }


The Control looks like this:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
 
<%= Html.Telerik().DropDownList()
.Name("Name")
.DataBinding(binding => binding.Ajax().Select("_SelectDrivers", "EntryList"))
.ClientEvents(events => events.OnDataBinding("onNameDataBinding"))
     
%>


The DataBinding takes a single parameters and returns a JsonResult.

The ClientEvents looks like this:
function onNameDataBinding(e) {
e.data = $.extend({}, e.data, { filterMode: 1
});
 }

Let me know if this helps at all.
Tags
Grid
Asked by
adam
Top achievements
Rank 1
Answers by
Craig Tarr
Top achievements
Rank 2
adam
Top achievements
Rank 1
Fethi
Top achievements
Rank 1
Alejandro
Top achievements
Rank 1
Share this question
or