Telerik Forums
UI for ASP.NET MVC Forum
1 answer
8.3K+ views
Hi Support,

I am trying to use FLEET_CUSTOM_FIELD_VALUE field for multiple data type while editing in grid,

so i tried using if condition for value coming through FLEET_CUSTOM_FIELD_DATATYPE  field in column but it's giving me error.

Any suggestion will be great.


public class CustomFieldValue
    {
        public int FLEET_ID { get; set; }
        public int FLEET_CUSTOM_FIELD_ID { get; set; }
        public string FLEET_CUSTOM_FIELD_VALUE { get; set; }
        public string FLEET_CUSTOM_FIELD_DESCRIPTION { get; set; }
        public string FLEET_CUSTOM_FIELD_DATATYPE { get; set; }
        public short FIELD_POSITION { get; set; }
        public string USER_UPDATE { get; set; }
    }

@(Html.Kendo().Grid<CustomFieldValue>()
            .Name("CustomFieldValue" + @ViewData["FLEET_ID"]) 
        .Sortable()
        .Pageable(paging =>
        {
            paging.Enabled(true);
            paging.Info(true);
            paging.PageSizes(true);
            paging.Numeric(true);
            paging.PreviousNext(true);
            paging.Refresh(true);
            paging.PageSizes(new int[5] { 5, 10, 15, 20, 25 });
        })
        .DataSource(dataSource => dataSource
            .Ajax()
                .Events(events =>
                {
                    events.RequestEnd("onCustomFieldValueRequestEnd");
                    events.Error("onCustomFieldValueListError"); 
                  
                })
                
            .PageSize(15)
            .Model(model =>
                {
                    model.Id(f => f.FLEET_CUSTOM_FIELD_ID);
                    model.Field(f => f.FLEET_CUSTOM_FIELD_DESCRIPTION).Editable(false);
                })

            .Read(read => read.Action("_CustomFieldValueList", "CustomFieldValueList", new { fleetId = ViewData["FLEET_ID"] }))
            .Update(update => update.Action("_CustomFieldValueListEdit", "CustomFieldValueList"))                  
        )
        .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
        .Editable(editable => 
        {
            editable.Mode(GridEditMode.InLine);            
        })
        .Reorderable(reorder => reorder.Columns(true))
        .Filterable()
        .Columns(columns =>
        {
            columns.Bound(f => f.FLEET_CUSTOM_FIELD_ID).Title(" ").Hidden();
            columns.Bound(f => f.FLEET_CUSTOM_FIELD_DATATYPE).Title(" ").Hidden();
            columns.Bound(f => f.FLEET_CUSTOM_FIELD_DESCRIPTION).Title("Description");

            if ("#=FLEET_CUSTOM_FIELD_DATATYPE#" == "D")
            {
                columns.Bound(f => f.FLEET_CUSTOM_FIELD_VALUE).Title("Field value").EditorTemplateName("_Date").Width(250);
            }
            else
            {
                columns.Bound(f => f.FLEET_CUSTOM_FIELD_VALUE).Title("Field value").Width(250);
            }
            
            
            columns.Command(command =>
            {
                command.Edit();
            }).Width(250).Title("Commands").HeaderHtmlAttributes(new { @style = "text-align:left; text-decoration:Underline;" });
        })
        .Events(e=>e.Edit("edit"))
        
    ) 
Dimo
Telerik team
 answered on 11 Oct 2013
1 answer
474 views
Please see attached code. I noticed that when the date portion was invalid I got the standard "date is not valid".  However if only the time portion was invalid, the form would validate.  So I added the custom rules scripting.  That seemed to do the trick.  However, now if the time is wrong, the message shows above the datetimepicker.  If the date is wrong, it shows below the datetimepicker.  If both are wrong it shows both messages duplicated.  I must be doing something wrong.  I've spend hours on this so I thought I'd ask.  thank you.

<script>

    $("#theform").kendoValidator({
        rules: {
            date: function (input) {
                if (!kendo.parseDate(input.val()))
                    return false;
                else return true;
            }
        },
        messages: {
            date: "Please enter a valid date/time."
        }
    });


</script>
<div id="sleepdelayform" class="centerform">
    <label>Select a date and time for when you'd like this task to be available:</label>

    <br /><br />
    @using (Ajax.BeginForm("SleepDelaySave", "Home", new AjaxOptions
    {
        UpdateTargetId = "sleepdelayform"
    }, new { id = "theform"}))
    {
        <input type="hidden" id="serialNumber" name="serialNumber" value="@(ViewBag.serialNumber)" />
        @(Html.Kendo().DateTimePicker()
            .Name("sleepdelaydatetimepicker")
            .Value(DateTime.Now)
        )  
        
        <br />
        <span class="k-invalid-msg" data-for="sleepdelaydatetimepicker"></span>
        <br />
        <input type="submit" class="k-button" value="Save" />
    }
</div>
Alexander Popov
Telerik team
 answered on 11 Oct 2013
1 answer
158 views
Hi,
I am trying to upgrade my ASP.Net MVC4 project to the latest version of Kendo UI. I used the upgrade wizard, but it broke my project and caused some issues. So now I am trying to upgrade manually.

My question is what is the purpose of creating bundles for the CSS and JavaScript files of Kendo UI in BundlesConfig.cs file. My current project has these bundles added, but if I remove them, everything runs fine.

Also my current project does not contain a reference to Kendo.Mvc assembly in the web.config file. So if this step is mandatory, then how is my project working now. And should I include it while upgrading to the latest version and what is the purpose of this

Thanks
Dimo
Telerik team
 answered on 11 Oct 2013
3 answers
173 views
I wanted to set the menu item selection based on a persisted item index but cannot see how I can access the menu item index from within the BindTo() section. I have worked around this in the code below by matching on the label but this is not ideal. Is it possible to compare the item index instead?  Thanks.

@(Html.Kendo().Menu()
      .Name("viewTypeMenu")
      .HighlightPath(false)
      .BindTo(Model.ViewTypeLabels, (item, value) =>
      {
          item.Text = value;
          item.Selected = (value == Model.SelectedViewTypeLabel);
      })
)
Ian
Top achievements
Rank 1
 answered on 10 Oct 2013
4 answers
237 views
Hello,

I have a simple Kendo Grid with an id (int) and a type (string) data types as columns. When i try to do an edit the value of that string is returned null in the controller instead of the value i provided in the grid.

Any ideas why this is happening?

Thanks!
Christos
Top achievements
Rank 1
 answered on 10 Oct 2013
5 answers
700 views
i have kendo scheduler configured as follows:
@(Html.Kendo().Scheduler<Dansinn.Models.Event>()
    .Name("scheduler")
    .Height(600)
    .Messages(messages =>
    {
        messages.Save(LocalizationResources.OK);
        messages.Cancel(LocalizationResources.Cancel);
    })
    .Views(views =>
    {
        views.DayView();
        views.WeekView(weekView => weekView.Selected(true));
        views.MonthView();
        views.AgendaView();
    })
    .Timezone("Etc/UTC")
    .Editable(editable => editable.TemplateName("Event").Resize(false))
    .DataSource(builder =>
    {
        builder.Events(events =>
        {
            events.Error("bs.kendo.scheduler.onError");
            events.RequestEnd("bs.kendo.onRequestEnd");
        });
        builder.Create(operationBuilder => operationBuilder.Action<ScheduleController>(controller => controller.Create(null)));
        builder.Update(operationBuilder => operationBuilder.Action<ScheduleController>(controller => controller.Update(null)));
        builder.Destroy(operationBuilder => operationBuilder.Action<ScheduleController>(controller => controller.Remove(null)));
        builder.Read(operationBuilder => operationBuilder.Action<ScheduleController>(controller => controller.Get(null)));
        builder.Model(factory =>
        {
            factory.Id(model => model.Id);
            factory.Field(model => model.Type);
            factory.Field(model => model.Start);
            factory.Field(model => model.End);
            factory.Field(model => model.Title);
            factory.Field(model => model.RecurrenceRule);
            factory.Field(model => model.RecurrenceException);
            factory.Field(model => model.Description);
            factory.Field(model => model.IsAllDay);
        });
    }))
In my computer I have currently timezone UTC+2. When I adding a new event and set start date to 17:10 (5:10 PM) it is send to server as 19:10 (7:10 PM). I think that scheduler should send to server 15:10 value (3:10 PM). Is it bug in scheduler or in my understanding?
Grzegorz
Top achievements
Rank 1
 answered on 10 Oct 2013
3 answers
134 views
Hi,

I  am working on a prototype for our new project, after the approval of this prototype we will move ahead and buy the license.

I want to load the grid with data from xml file, display it with all features (sorting, paging, filtering, etc.)

Below is the code I use in Controller and Razor

        public ActionResult Index()
        {
            return View(GetQueueItems());
        }

        private static IEnumerable<TmpQueueModel> GetQueueItems()
        {
            IList<TmpQueueModel> ieTmpQueueModel = null;
            TmpQueueModel tmpQueueModel = null;
            try
            {
                DataSet dsQueue = new DataSet();
                dsQueue.ReadXml("\\App_Data\\Queue.xml");

                if (dsQueue.Tables[0].Rows.Count > 0)
                {
                    ieTmpQueueModel = new List<TmpQueueModel>();
                    foreach (DataRow dr in dsQueue.Tables[0].Rows)
                    {
                        tmpQueueModel = new TmpQueueModel();
                        tmpQueueModel.Action = dr["Action"].ToString();
                        //tmpQueueModel.AssignedDate = dr["AssignedDate"].ToString();
                        //tmpQueueModel.AssignedTo = dr["AssignedTo"].ToString();
                       // tmpQueueModel.Comment = dr["Comment"].ToString();
                        tmpQueueModel.ConsumerFirstName = dr["ConsumerFirstName"].ToString();
                        tmpQueueModel.ConsumerId = dr["ConsumerId"].ToString();
                        tmpQueueModel.ConsumerLastName = dr["ConsumerLastName"].ToString();
                        tmpQueueModel.ExternalReferenceID = dr["ExternalReferenceID"].ToString();
                        tmpQueueModel.First_Name = dr["First_Name"].ToString();
                        //tmpQueueModel.IsReserved = (bool)dr["IsReserved"];
                        tmpQueueModel.Last_Modified_Date_and_Time = dr["Last_Modified_Date_and_Time"].ToString();
                        tmpQueueModel.Last_Name = dr["Last_Name"].ToString();
                        tmpQueueModel.LastModifiedBy = dr["LastModifiedBy"].ToString();
                        tmpQueueModel.Medicaid_No_ = dr["Medicaid_No_"].ToString();
                        tmpQueueModel.No_ = dr["No_"].ToString();
                        tmpQueueModel.PacketReceivedDate = dr["PacketReceivedDate"].ToString();
                        //tmpQueueModel.QueueHistoryDate = Convert.ToDateTime(dr["QueueHistoryDate"]);
                        tmpQueueModel.QueueId = Convert.ToInt32( dr["QueueId"]);
                        //tmpQueueModel.QueueStatus = dr["QueueStatusId"].ToString();
                        ieTmpQueueModel.Add(tmpQueueModel);
                    }
                }
                return ieTmpQueueModel;
            }
            catch
            {
                return null;
            }
        }

        public ActionResult QueueItems_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(GetQueueItems().ToDataSourceResult(request));
        }


----------XXXXXXXXXXX------------
@model IEnumerable<GenericQueue.Models.TmpQueueModel>

@(Html.Kendo().Grid(Model)    
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ConsumerId).Groupable(false);      
        columns.Bound(p => p.PacketReceivedDate);
        columns.Bound(p => p.First_Name );
        columns.Bound(p => p.Last_Name);        
    })
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()   
        .PageSize(5)
        .Read(read => read.Action("QueueItems_Read", "Grid"))    
    )
)


Thanks in advance.

Regards,
Ravi
Ravi
Top achievements
Rank 1
 answered on 10 Oct 2013
9 answers
857 views
I have a project working fine in ASP.Net MVC 4 with kendo UI 2012.2.710 developed in VS2010.

I have recently installed VS2012 and there I have Kendo 2012.3.1114. I just copied all the code from the VS2010 to VS2012 and it all just worked except for one small point. I have a nested grid and I use a template for the detail. That template is shown below. It works fine in the 2010 project but 2012 always says "Uncaught Error: Invalid template:" and the template is identical. If I comment out the .ClientTemplateId statement, the main grid displays just fine. If I paste the template into its own Partial View and display it separately, it displays just fine but it always errors as a template.

I have tried commenting out parts of the template, even getting to the point where it o nly has the Name and ToClientTemplate calls and it STILL errors. So I just wonder if something is broken with templates in the latest version of Kendo or the latest version of VS. The template is below:
<script id="paneTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<AWSQBCC.Models.Pane>()
    .Name("Panes_#=LiteId#")
    .Columns(columns =>
    {
        //columns.Bound(p => p.PaneId);
        columns.Bound(p => p.Sequence);
        columns.Bound(p => p.LiteId).Hidden();
        columns.ForeignKey(p => p.GlassId, (System.Collections.IEnumerable)ViewData["glasses"], "GlassId", "GlassType").Title("Glass Type");
        columns.Command(command => { command.Edit(); command.Destroy(); });
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Sort(sort =>
        {
            sort.Add(p => p.Sequence);
        })
        .Read(read => read.Action("Pane_Read", "Lite", new { id = "#=LiteId#" }))
        .Destroy(destroy => destroy.Action("Pane_Delete", "Lite"))
        .Update(update => update.Action("Pane_Update", "Lite"))
        .Create(create => create.Action("Pane_Create", "Lite", new { id = "#=LiteId#" }))
        .Model(model =>
        {
            model.Id(p => p.PaneId);
            model.Field(p => p.PaneId).Editable(false);
            model.Field(p => p.LiteId).Editable(false);
            model.Field(p => p.GlassId);
        })
        .Events(events => { events.Error("error"); })
    )
    .ToolBar(commands => commands.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    //.Events(events => events.DataBound("refresh"))
    .ToClientTemplate())
</script>
Any help much appreciated.
Daniel
Telerik team
 answered on 10 Oct 2013
3 answers
660 views
How can I force the grid detail/template datasource to refresh in the detailExpand event handler?

function detailExpand(e) {
try { 
     var dataItem = e.sender.dataItem(e.masterRow);
     if ($.inArray(dataItem.Key, expanded) == -1) {
      expanded.push(dataItem.Key);
}
} catch (ex) {
expanded = [];
}
}
Vladimir Iliev
Telerik team
 answered on 10 Oct 2013
1 answer
460 views
Hello -

I have created a POCO class (called User) which I decorated some properties with a custom Editor Template. The custom Editor Template (called WorkflowUsers) simply prints the text "HI". I have a grid set up, which displays all of the Users. It has a button which launches the editor pop-up, allowing you to create a new User. The "Domain" property properly uses the custom Editor which I have specified using the UIHInt, however the Roles property does not even show (no display label nor custom editor) on the popup.  I have tried making it  a List, making it non-virtual. I am confused.

Note: I am using the Trial version, as my full-version won't be purchased until the end of the week due to my company's billing process.

[Required]
[DisplayName("Domain")]
[MaxLength(100)]
[UIHint("WorkflowRoles")]
public string Domain { get; set; }
 
 
[DisplayName("Roles")]
[UIHint("WorkflowRoles")]
[Required]
public virtual ICollection<Role> Roles { get; set; }
Petur Subev
Telerik team
 answered on 10 Oct 2013
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
DropDownButton
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?