Kendo Grid make fields Not Editable Not Required

2 Answers 43 Views
Grid
Joshua
Top achievements
Rank 1
Iron
Joshua asked on 30 Jan 2025, 05:28 PM
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; }

    }

 

Joshua
Top achievements
Rank 1
Iron
commented on 31 Jan 2025, 04:12 PM

I am sorted on questions 2-4 on this from another post. So question 1 is the only piece I still need assistance with from this post.

2 Answers, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 1
Iron
answered on 31 Jan 2025, 09:52 PM
I no longer need this question but I cant find any way to delete it so putting here.
0
Alexander
Telerik team
answered on 04 Feb 2025, 01:06 PM

Hi Joshua,

Great job on finding the majority of the solutions based on an another forum post! Would it be possible for you to link it within this discussion as well. As this may benefit clients, if they happen to stumble upon this particular post.

As far as the first question goes, I try to link to a previous discussion of ours which partially gives a potential alternative - namely through the custom Popup Editing functionality:

I hope this proves helpful :)

Kind Regards,
Alexander
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Joshua
Top achievements
Rank 1
Iron
Answers by
Joshua
Top achievements
Rank 1
Iron
Alexander
Telerik team
Share this question
or