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

Editor Template

3 Answers 74 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert
Top achievements
Rank 1
Robert asked on 15 Nov 2011, 05:02 PM
Hi Im fairly new to telerik mvc and Open Access.
I have managed to get working a basic CRUD example.  However I now wish to have my own custom editor. 

I cannot find an example of how to link to my own custom editor.

@model IEnumerable<MacrailSQL.myCompanies>
 
 
            
 
 
            
@(Html.Telerik().Grid(Model)
                .Name("GridUsers")
                .DataKeys( keys =>   keys
                    .Add( o => o.Company_ID)
                    .RouteKey("Company_ID"))
                .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new { style = "margin-left:0" }))
                .DataBinding(dataBinding => dataBinding
                    .Ajax()
                        .Select<CompanyController>(o => o._select())
                        .Insert<CompanyController>(o => o._insert())
                        .Update<CompanyController>(o => o._update())
  
                        )
 
 
                .Sortable()
                .Filterable()
                .Reorderable(cf => cf.Columns(true))
                .Resizable(cf => cf.Columns(true))
                .Pageable()
                .Scrollable()
                .Selectable()
                 
 
 
                .Columns(columns =>
                {
 
                    columns.Command(commands =>
                    {
                        commands.Edit()
                            .ButtonType(GridButtonType.Image);
                    }).Width(80);
                     
                    columns.Bound(o => o.Company_ID).Title("Company ID");
                    columns.Bound(o => o.Company_Name).Title("Company Name");
                    columns.Bound(o => o.Date_Created).Title("Date Created");
                    columns.Bound(o => o.Date_Updated).Title("Date Updated");
                    columns.Bound(o => o.Status).Title("Status")
 
                      .ClientTemplate("<input type='checkbox' disabled='disabled' name='U_status' <#= Status? \"checked='checked'\" : \"\" #> />");
 
 
 
 
 
                })
 
               .Editable(editing => editing.Mode(GridEditMode.PopUp))
        
 
 
      )


@model IEnumerable<MacrailSQL.myCompanies>
 The above is where i think the problem lies as most examples seem to point at ("SometingModel")

public IEnumerable<MacrailSQL.myCompanies> GetCompanies()
       {
            
            
           return db.myCompanies.Select(c => new MacrailSQL.myCompanies
           {
               Company_ID = c.Company_ID,
               Company_Name = c.Company_Name,
               Date_Created = c.Date_Created,
               Date_Updated = c.Date_Updated
           }).ToList();
       }

This is what I'm using to populate my grid.

Any help would be great



3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Nov 2011, 02:29 PM
Hi Robert,

There are several examples on how to set custom editor templates. You can follow one of the links below to check them out :

Kind regards,

Daniel
the Telerik team

 

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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Dennis
Top achievements
Rank 1
answered on 12 Jul 2012, 10:33 PM
In the example for Client Edit Templates what is "ClientEmployee (Editor)"? Is it a control?
0
Dennis
Top achievements
Rank 1
answered on 12 Jul 2012, 10:51 PM
What I need to do is have certain fields show up for update and other fields show up search. My model has say 6 fields and when the form loads I want all six to show. When I edit the record I only want the edit form to popup with 2 fields and when I insert I want 5 fields to display in the popup. I know of HiddenInput(DisplayValue = false)] and [ScaffoldColumn(false)] but the problem is whatever I hide will hide for insert/update. I am aware of Client Edit Templates but if that's the only way can you please explain how I do this?
Model:
 
public class CodeModel
   {
       [MaxLength(2)]
       [DisplayName("Code ID")]
       [UIHint("Codes"), Required]
       public string CodeID { get; set; }
 
       [HiddenInput(DisplayValue = false)]
       public string Title { get; set; }
 
       [HiddenInput(DisplayValue = false)]
       public string Status { get; set; }
 
       public bool Active { get; set; }
 
       [HiddenInput(DisplayValue = false)]
       public string Category { get; set; }
 
       [DisplayName("User ID")]
       [ScaffoldColumn(false)]
       public int UserID { get; set; }
 
   }

Grid:
@(Html.Telerik().Grid<hrmsMVC.Areas.HRMS.Models.CodeModel>()
        .Name("CodeManager")
            .DataKeys(keys =>
            {
                keys.Add(c => c.CodeID);
            })
            .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText).ImageHtmlAttributes(new { style = "margin-left:0" }))
            .DataBinding(dataBinding =>
            {
                dataBinding.Ajax()
                    .Select("_Filtering", "CodeManager", new { classifications = @ViewBag.SelectedCatgory })
                    .Update("_SaveAjaxEditing", "codeManager", new { classifications = @ViewBag.SelectedCatgory })
                    .Insert("_InsertAjaxEditing", "CodeManager", new { classifications = @ViewBag.SelectedCatgory });
            })
        .Columns(columns =>
        {
 
            columns.Bound(o => o.CodeID).Width(120);
            columns.Bound(o => o.Title).Width(200);
            columns.Bound(o => o.Active).ClientTemplate("<input type='checkbox' disabled='disabled' name='Active' <#=Active ? checked='checked' : '' #> />").Width(120);
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.ImageAndText);
            }).Width(180).Title("Commands");
 
        })
            .Editable(editing => editing.Mode(GridEditMode.InForm).InsertRowPosition(GridInsertRowPosition.Top))
            .Sortable(sorting => sorting
            .SortMode(GridSortMode.SingleColumn)
            .AllowUnsort(true)
            .OrderBy(order =>
                {
                    order.Add(o => o.CodeID);
                })
             )
             .Pageable()
                 .Resizable(resizing => resizing.Columns(true))
            .Filterable()
 
        )


Thank you very much.
Tags
General Discussions
Asked by
Robert
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Dennis
Top achievements
Rank 1
Share this question
or