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

[Solved] Issue in populating data in Combobox inside a Telerik Grid

0 Answers 42 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.
Gurunath
Top achievements
Rank 1
Gurunath asked on 17 Nov 2011, 08:53 AM
Hi,

I have a combobox inside a Telerik grid. I am binding the data to the combobox OnRowDataBound event of the grid.

I am able to get the data in the call back function and bind it to the combobox. But  the data is not getting populated in the combobox and it looks like it is disabled.

Please let me know if I am missing anything here. 

@(Html.Telerik().Grid<DirectoryViewModel>()
            .Name("gridPartitions")
            .DataKeys(keys =>
            {
                keys.Add(k => k.Directory_ID);
            })
            .DataBinding(dataBinding =>
            {
                dataBinding.Ajax()
                    .Select("_Grid_SelectDirectories", "Request", new { Guid = @Model.Guid })
                    .Delete("_Grid_DeleteDirectories", "Request", new { Guid = @Model.Guid });
            })
                .Columns(columns =>
                {
                    columns.Bound(c => c.Directory_ID).Visible(false);
                    columns.Bound(c => c.Path).Width(100);
                   // columns.Bound(c => c.Access).Width(100);
 
                   columns.Bound(c => c.Directory_ID)
                   .Title("Permission Sets")
                   .ClientTemplate(
 
                   Html.Telerik().ComboBox()
                         .Name("<#= Directory_ID#>" + "_Combobox")
                         .Enable(false)
                         .AutoFill(true)
                         .ToHtmlString()
                     );
                                                              
                    columns.Command(cmd =>
                    {
                        cmd.Delete().ButtonType(GridButtonType.BareImage);
                    });
 
                })
                 
                      .ClientEvents(events =>
                     {
                         events.OnRowDataBound("AddAccess");
 
                      })
                       
                    .Pageable()
                    .Sortable()
                    .Filterable()
                    )
function AddAccess(e) {
 
 
     var accessId = "#" + e.dataItem.Directory_ID + "_Combobox";
 
       url = '@Url.Action("GetAccess", "Request")';
 
         $.post(url, { nodeId: e.dataItem.Directory_ID, Guid: $("#Guid").val() },
 
           function (data) {
 
 
                  var combobox2 = $(accessId).data('tComboBox');
 
                  alert(data.length);
                  combobox2.close();
                  combobox2.dataBind(data);
 
              });
 
           }
[AcceptVerbs(HttpVerbs.Post)]
         public JsonResult GetAccess(int nodeId)
         {
 
             var access = _requestRepository.GetPermissionSetsAppliedAtNode(nodeId).ToList();
 
             return new JsonResult { Data = new SelectList(access, "PermissionSet_ID", "Name") };
         }

Tags
Grid
Asked by
Gurunath
Top achievements
Rank 1
Share this question
or