Josh
Josh

Reputation: 1

Telerik Kendo .Net Core Razor Grid Make Fields Not Editable Not Required

Im having difficulty making customizations to my grid. Ive left my commented out code in there for some items I have tried and didnt work. Ive listed out below what I am trying to do. Any help would be greatly appreciated

  1. Trying to give PartyRoleOverride a drop down list on edit
  2. Trying to make fields not editable. Code is currently in there below and just does nothing
  3. Make fields not required. All fields are currently required and did not specify required anywhere but only see how to make things required?
  4. Making isProSe field show as a yes/no rather than true false
    @page
    @addTagHelper *, Kendo.Mvc
@using Kendo.Mvc.UI
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
@Html.AntiForgeryToken()

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://unpkg.com/jszip/dist/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2024.4.1112/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2024.4.1112/js/kendo.aspnetmvc.min.js"></script>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/themes/10.0.1/default/default-ocean-blue.css">

                   <div id="parties-scheduling" style="margin-right:8px;border:none;padding:0;color:black;">
                        <div id="PartiesTopRowInfo">
                            @Html.Kendo().Grid(Model.MiscellaneousInfo.PartyInfoList).Name("PartyGrid").ToolBar(x => 
                              x.Create()).Size(ComponentSize.Small).Editable(GridEditMode.PopUp).Resizable(r => r.Columns(true)).Columns(col =>
                             {                                
                                 col.Bound(c => c.Name.BuiltName).Title("Name").Width(175);
                                 col.Bound(c => c.PartyRole).Title("Role").Width(150);
                                 //col.Bound(c => c.PartyRoleOverride).Title("Role Override").Width(150).EditorTemplateName("rolesEditor");
                                 // col.Bound(c => c.PartyRoleOverride).Title("Role Override").Width(150).ClientTemplate("#=rolesEditor#");
                                     // col.Bound(c => c.PartyRoleOverride).Title("Role Override").Width(150).EditorTemplateComponentName("rolesEditor"); 
                                 col.Bound(c => c.PartyRoleOverride).Title("Role Override").Width(150);
                                 col.Bound(c => c.AppearanceType).Title("Appear Type").Width(100);
                                 col.Bound(c => c.Timely).Width(60);
                                 col.Bound(c => c.ServiceType).Width(150);
                                 col.Bound(c => c.DateServed).Width(100);
                                     col.Bound(c => c.isProse).Title("ProSe").Width(55);/* .ClientTemplate("#= MyBool ? 'Yes' : 'No' #"); */
                                 col.Command(c => 
                                 {
                                     c.Edit();
                                     c.Destroy();
                                 }).Width(170);
                             }).Sortable().DataSource(dataSource =>dataSource
                             .Ajax()
                             .Read(r => r.Url("/Appearances/MiscellaneousInformation?handler=Read").Data("forgeryToken"))
                             .Update(r => r.Url("/Appearances/MiscellaneousInformation?handler=Update").Data("forgeryToken"))
                             .Create(r => r.Url("/Appearances/MiscellaneousInformation?handler=Create").Data("forgeryToken"))
                             .Destroy(r => r.Url("/Appearances/MiscellaneousInformation?handler=Destroy").Data("forgeryToken"))
                              .Model(m => m.Id(id => id.PartyAppearanceID))
                              .Model(m => m.Field(party => party.PartyRole).Editable(false))
                              .Model(m => m.Field(party => party.PartyRoleOverride).Editable(false))
                              .Model(m => m.Field(party => party.Name.BuiltName).Editable(true))
                              .Model(m => m.Field(party => party.isProse).Editable(false))
                              // .Model(m=> m.Field(party => party.PartyRoleOverride).DefaultValue(new List<String>{
                              //     "Role1","Role2","Role3"
                              // }))
                              )
                              
                         </div>
                    </div>

 function rolesEditor(container, options) {
     $('<input name="PartyRoleOverride" style="width:300px;">')
         .appendTo(container)
         .kendoDropDownList({
             autoBind: false,
             dataTextField: "RoleDesc",
             dataValueField: "RoleID",
             dataSource: {
                 data: roles
             }
         });
 }

var roles = [{
     "RoleID": 1,
     "RoleDesc": "Administrator"
 }, {
     "RoleID": 2,
     "RoleDesc": "Bank"
 }, {
     "RoleID": 3,
     "RoleDesc": "Guardian"
 }];


public class MiscellaneousInformationModel : PageModel
    {
        public CoreFileInfoObj CoreFileInfoObj { get; set; } = new CoreFileInfoObj();
        public SharedFunctions sharedFunctions { get; set; }

        [BindProperty]
        public MiscellaneousInfoDTO MiscellaneousInfo { get; set; } = new MiscellaneousInfoDTO();
}




    public class MiscellaneousInfoDTO
    {
        public List<PartyInfoDTO> PartyInfoList { get; set; }

    }


public class PartyInfoDTO
{
    public int PartyAppearanceID { get; set; }

    public NameDTO Name { get; set; }

    public string PartyRole { get; set; }

    public string PartyRoleOverride { get; set; }

    public string AppearanceType { get; set; }

    public Boolean Timely { get; set; }

    public string ServiceType { get; set; }

    public DateTime? DateServed { get; set; }

    public Boolean isProse { get; set; }
}


    public class NameDTO
    {
        public NameDTO()
        {

        }

        public string FirstName { get; set; }

        public string MiddleName { get; set; }
        public string LastName { get; set; }

        public string Organization { get; set; }

        public string Suffix { get; set; }

        public string BuiltName { get; set; }

    }

Left commented code in showing what I tried for making Boolean show as Yes/No rather than true/false.

Left commented code of all different syntaxes I found for trying to give drop down list for PartyRoleOverride field.

Left code in trying to make fields not editable

Making fields required/not I dont see anything being able to specify not required as I thought it was implicitly not?

Upvotes: 0

Views: 12

Answers (0)

Related Questions