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

[Solved] Limitation in UIHINT

1 Answer 178 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.
Howard
Top achievements
Rank 1
Howard asked on 24 May 2012, 07:41 AM
Hi Telerik team,

Are there any limitations on how many UIHINTS you can use in a model? I've got 4 UIHINTS,  1 for date and other 3 for dropdownlist, and only first two dropdownlist works. when I comment the first one, then the last one works as well.

This is my model
public class HireBookingTimesheetModel
    {
        public int TIMESHEET_ID { get; set; }
        public int BOOKING_ID { get; set; }
         
        [UIHint("_Personnel"), Required]
        public int PERSONNEL_ID { get; set; }
         
        public string PERSONNEL_NAME { get; set; }
         
        [UIHint("_Date"), Required]
        public string USAGE_DATE { get; set; }
        public decimal HOURS_USED { get; set; }       
         
        [UIHint("_HireoutType"), Required]
        public int HIREOUT_TYPE_ID { get; set; }
 
        [UIHint("_HourType"), Required]
        public string HOUR_TYPE { get; set; }
}

These are my UIHINTS
@(Html.Telerik().DropDownList()
        .Name("Personnel")
        .BindTo(new SelectList((System.Collections.IEnumerable)ViewBag.Personnels, "PERSONNEL_ID", "PERSONNEL_NAME"))
)
@(Html.Telerik().DropDownList()
        .Name("HourType")
        .BindTo(new SelectList((System.Collections.IEnumerable)ViewBag.HireoutTypes, "HIREOUT_TYPE_ID", "HIREOUT_TYPE_DESCRIPTION"))
)
@(Html.Telerik().DropDownList()
        .Name("HourType")
        .BindTo(new SelectList((System.Collections.IEnumerable)ViewBag.HourTypes, "Value", "Text"))
)

This is my Controller
//Hire timesheet
        public ActionResult HireBookingTimesheetQuery(Int32 bookingId)
        {
            ViewData["bookingId"] = bookingId;
            SelectHire _selectHire = new SelectHire();
            var _hireTimesheetList = _selectHire.HireBookingTimesheets(bookingId).FirstOrDefault();
            if (_hireTimesheetList != null)
            {
                ViewData["lineNo"] = _hireTimesheetList.LINE_NUMBER;
            } 
            
            ViewBag.Personnels = (new[] { new PersonnelSelectionModel() { PERSONNEL_ID = 0, PERSONNEL_NAME = "" } }).Concat(new ReferenceFileSelection().Personnel());
            ViewBag.HourTypes = (new[] { new SelectListItem() { Value = "0", Text = "" } }).Concat(new ReferenceFileSelection().HourType());           
            ViewBag.HireoutTypes = (new[] { new HireoutTypeSelectionModel() { HIREOUT_TYPE_ID = 0, HIREOUT_TYPE_DESCRIPTION = "" } }).Concat(new ReferenceFileSelection().HireoutType());
 
            return PartialView("_HireBookingTimesheetList", _hireTimesheetList);
        }
 
        [GridAction]
        public ActionResult _HireBookingTimesheetQuery(Int32 bookingId)
        {
            //hire timesheet list
            SelectHire _selectHire = new SelectHire();
            var _hireTimesheetList = _selectHire.HireBookingTimesheets(bookingId);
            return View(new GridModel { Data = _hireTimesheetList });
        }

This is my view
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using AusFleet.Data.Models.Hire;
@model HireBookingTimesheetModel
<script type="text/javascript">
 
    function onEditHireTimesheet(e) {
        $("#LINE_NUMBER", $(e.form)).attr('readonly', 'readonly').attr('style', 'border-style:none');
    }
 
    function CheckDates(e) {
 
    }
 
</script>
@(Html.Telerik().Grid<HireBookingTimesheetModel>()
            .Name("HireBookingTimesheetList_" + ViewData["bookingId"])
            .HtmlAttributes(new { @style = "font-size: 10pt; margin-left:-14px; margin-right:-14px; margin-bottom:-4px;" })
            .Sortable(sorting => sorting.Enabled(true))
            .Pageable(paging => paging.Enabled(true).PageSize(10))
            .Resizable(resize => resize.Columns(true))
            .Localizable("en-AU")
            .Footer(true)
            .DataBinding(dataBinding => dataBinding.Ajax().Select("_HireBookingTimesheetQuery", "Hire", new { bookingId = ViewData["bookingId"] })
                                                          .Update("_HireBookingTimesheetEdit", "HireEdit")
                                                          .Insert("_HireBookingTimesheetAdd", "HireEdit", new { bookingId = ViewData["bookingId"] }))
            .DataKeys(keys => keys.Add(f => f.TIMESHEET_ID))
            .ToolBar(commands =>
            {
                commands.Insert().ButtonType(GridButtonType.Text).HtmlAttributes(new { @style = "color: black;" });
            })
            .Columns(columns =>
                    {
 
                        columns.Bound(f => f.LINE_NUMBER).Title("Line no").Width(50);
                        columns.Bound(f => f.USAGE_DATE).Title("Date").Format("{0:dd/MM/yyyy}"); ;
                        columns.Bound(f => f.PERSONNEL_ID).Title("Personnel").ClientTemplate("<#=PERSONNEL_NAME #>");
                        columns.Bound(f => f.HOURS_USED).Title("Hours");
                        columns.Bound(f => f.HOUR_TYPE).Title("N/O");
                        columns.Bound(f => f.HIREOUT_TYPE_ID).Title("Hour code").ClientTemplate("<#=HIREOUT_TYPE_DESCRIPTION #>");
                        columns.Bound(f => f.CHARGE_RATE).Title("Rate");
                        columns.Bound(f => f.TOTAL_CHARGE).Title("Total");
 
                        columns.Command(commands =>
                        {
                            commands.Edit().ButtonType(GridButtonType.Text);
 
                        }).Width(200).HeaderHtmlAttributes(new { @style = "font-weight:bolder;" }).Title("Commands");
                    })
               .Editable(editing => editing.Mode(GridEditMode.InLine)
                                .DefaultDataItem(new HireBookingTimesheetModel
                                {
                                    LINE_NUMBER = (short)((ViewData["lineNo"] != null ? int.Parse(ViewData["lineNo"].ToString()) : 0) + 1)
                                }))
               .ClientEvents(events => events.OnEdit("onEditHireTimesheet")).HtmlAttributes(new { @style = "color: black;" })
               )

Please let me know, what am I doing wrong or are there any limitations?

Cheers
Niroj

1 Answer, 1 is accepted

Sort by
0
Licenses
Top achievements
Rank 1
answered on 24 May 2012, 09:56 AM
Could be nothing or could be the issue:

Your last 2 editor templates, the DropDownLists both have the same name.

Try changing them to unique names or use DropDownListFor<> instead (so the names are generated from your model property names)
Tags
Grid
Asked by
Howard
Top achievements
Rank 1
Answers by
Licenses
Top achievements
Rank 1
Share this question
or