Telerik Forums
UI for ASP.NET MVC Forum
0 answers
189 views
Does RangeSliderFor actually work with the Range data annotation?
When I use it there is an extra value added to ModelState. Say I bind RangeSlider to a 2 item array property of type Double called "Numbers", in the controller, in ModelState I see 3 separate keys in ModelState:

Numbers[0]
Numbers[1]
Numbers

Although the slider values are valid, key 3 (Numbers) has an error against it. Why does this value appear and how do I get rid of it?
Matt
Top achievements
Rank 1
 asked on 02 Jul 2012
0 answers
227 views
I am using a MVC DatePicker control defined as follows in my Date editor template:
Html.Kendo().DatePicker()
            .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(""))
            .Min(new DateTime(2000, 1, 1))
            .Max(new DateTime(9999, 12, 31))
            .Value((DateTime)ViewData.TemplateInfo.FormattedModelValue)

It is working fine in all PC-based browsers.  However, when using Safari on the iPad it works a bit differently.  Firstly, when clicking the little calendar icon next to the date field calendar, no calendar pops up.  Instead, when I click in the date field, the iPad "slot-machine" spinner control comes up whereby one can select a date.  This is cool and I actually like that.  However, no matter what date I select using this spinner control, the validation kicks in saying "Please enter a valid date".  I've even tried altering the format with the .Format statement in my date picker.  Whatever new format I define does apply correctly (once again, confirmed by using any pc-based browser), but still no luck in getting a valid date set in my iPad.  Please help.

EDIT: In the Q2-2012 release of KendoUI, the control now displays the calendar pop up when clicking the little calendar icon next to the date field.  However, this calendar popup does not respond to any touch events at all.
Shawn
Top achievements
Rank 2
 asked on 01 Jul 2012
3 answers
167 views
Any examples using the Mobile Layout in a MVC3 application? Or any other Mobile widget in MVC3 for that matter?
Sebastian
Telerik team
 answered on 29 Jun 2012
0 answers
129 views

Hi,

Currently in KendoUI for MVC, one can load the columns for a KendoGrid by writing this in the view,

@(Html.Kendo().Grid<Object>(
   
.Name("Some name")
   
.Columns(columns =>
   
{
        columns
.LoadSettings((IEnumerable<GridColumnSettings>)ViewData["Columns"]);
   
})
   
// ...
)

where ViewData["columns"] has been set in the controller.

I'm wondering if there is some similar way of loading several series for a KendoChart. I know I could probably accomplish this using javascript and an AJAX call, but I would rather use Razor for as much as I can, and I would like to avoid making too many server calls.

Thanks!

Alex
Top achievements
Rank 1
 asked on 29 Jun 2012
0 answers
244 views
In the typical "Index" view of my asp.net MVC app, I'm using the grid to display the readonly list of records.  For boolean columns, it is displaying a dropdown list control.  How can I change this to use a checkbox instead?
Shawn
Top achievements
Rank 2
 asked on 28 Jun 2012
2 answers
3.1K+ views
I'm using the new KendoUI Extensions for MVC and while they work I'm having this weird issue where the Upload component seems to be just returning the filename of the file and not the full path.

Does anyone know why?  This has never happened before, so I'm a little confused as to why it's happening now.

[HttpPost]
public virtual ActionResult CreateTable(IEnumerable<HttpPostedFileBase> files)
{
    string tableName = Request["CreateTableViewModel.TableName"].ToString();
    bool blnOk = true;
 
    try
    {
        if (string.IsNullOrEmpty(tableName))
        {
            ModelState.AddModelError("CreateTableViewModel.TableName", "Table Name is required.");
            blnOk = false;
        }
 
        if (files == null)
        {
            ModelState.AddModelError("files", "CSV file is required");
            blnOk = false;
        }
 
        if (!blnOk)
        {
            return RedirectToAction(MVC.Data.CreateTable());
        }
 
        foreach (var hpf in files)
        {
            if (hpf.ContentLength == 0)
            {
                ModelState.AddModelError("files", "You must select a file to upload.");
                return RedirectToAction(MVC.Data.CreateTable());
            }
 
            _sqlService.CreateDatasource(hpf.FileName, tableName);
        }
 
        return RedirectToAction(MVC.Data.Success());
    }
    catch (Exception ex)
    {
        ModelState.AddModelError("", ex.Message);
        return RedirectToAction(MVC.Data.CreateTable());
    }
}

The "hpf.FileName" is the filename only and not the full path to the file.

Thanks,

King Wilder
King Wilder
Top achievements
Rank 2
 answered on 28 Jun 2012
1 answer
756 views
I just ran into a situation with the Beta where setting the default value of a Guid column throws an error. Here is some pseudocode:

    public class FloorPlanModel
    {
        [ScaffoldColumn(false)]
        public Guid Id { get; set; }
 
       [ScaffoldColumn(false)]
        public Guid PropertyId { get; set; }
 
        public string Name { get; set; }
 
        public decimal Bedrooms { get; set; }
}

And the following Grid code (unnecessary parts omitted):
@(Html.Kendo().Grid<FloorPlanModel>()
    .Name("floorPlanGrid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Name);
        columns.Bound(p => p.Bedrooms).Width(80).EditorTemplateName("Bedrooms");
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(false)
        .Model(model => {
                            model.Id(p => p.Id);
                            model.Field(p => p.PropertyId).DefaultValue(Model.Id);
                            model.Field(p => p.Bedrooms).DefaultValue(1);
        })
    )
)
...where Model.Id is also a Guid, I get this error:

Cannot serialize objects of type System.Guid

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotSupportedException: Cannot serialize objects of type System.Guid

Source Error: 

Line 254:        </div>
Line 255:        <div class="tab-pane" id="floorplans">
Line 256:            @(Html.Kendo().Grid<AdvancedREI.Web.Models.FloorPlanModel>()
Line 257:                .Name("floorPlanGrid")
Line 258:                .Columns(columns =>

Source File: d:\TFSWorking\AdvancedREI\Development\Development\src\AdvancedREI.Web\Views\Properties\_Edit.cshtml    Line: 256 

Stack Trace: 

[NotSupportedException: Cannot serialize objects of type System.Guid]
   Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2 object) +1180
   Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2 object) +354
   Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2 object) +354
   Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2 object) +354
   Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2 object) +354
   Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2 object) +354
   Kendo.Mvc.Infrastructure.JavaScriptInitializer.Initialize(String id, String name, IDictionary`2 options) +260
   Kendo.Mvc.UI.Grid`1.WriteInitializationScript(TextWriter writer) +1801
   Kendo.Mvc.UI.ViewComponentBase.WriteHtml(HtmlTextWriter writer) +72
   Kendo.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) +1491
   Kendo.Mvc.UI.ViewComponentBase.ToHtmlString() +106
   Kendo.Mvc.UI.ViewComponentBuilderBase`2.ToHtmlString() +16
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, Object content) +17
   ASP._Page_Views_Properties__Edit_cshtml.Execute() in d:\TFSWorking\AdvancedREI\Development\Development\src\AdvancedREI.Web\Views\Properties\_Edit.cshtml:256
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
   Glimpse.Mvc3.Plumbing.GlimpseView.Render(ViewContext viewContext, TextWriter writer) +258
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
   Castle.Proxies.AsyncControllerActionInvokerProxy.InvokeActionResult_callback(ControllerContext controllerContext, ActionResult actionResult) +21
   Castle.DynamicProxy.AbstractInvocation.Proceed() +72
   Glimpse.Mvc3.Interceptor.InvokeActionResultInterceptor.Intercept(IInvocation invocation) +415
   Castle.DynamicProxy.AbstractInvocation.Proceed() +316
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +33
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +613
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +613
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +263
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +240
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__4(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +607
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

I can switch the Model to a string, set the default to Model.Id.ToString(), and then get it back into a Guid on the backend, but that is obviously not ideal.

Any chance this could get fixed before RTM?

Thanks!
Rosen
Telerik team
 answered on 28 Jun 2012
6 answers
145 views
Hello Team:
With the introduction of supporting MVC controls in Kendo UI, my question is, are you guys going to be developing two separate lines of controls, one for Kendo UI and another as a MVC wrapper in parallel ?
Or will both series merge into one set?

Thanks!
..Ben
Ben Hayat
Top achievements
Rank 2
 answered on 28 Jun 2012
2 answers
530 views
Hi, 
I have a question regarding posting data to MVC controller (action).
If we use Razor, what would be the best practice?
Could you give me some example for let's say login page? Something like this?

html: what is the best practice using Kendo UI, HTML5, MVC?

<div id="view">
 <input type="text" data-bind="value: UserName" required  />
 <input type="text" data-bind="value: Password" required  />
  <button data-bind="click: LogOn">Log On</button>
 </div>
 <script>
	$(document).ready(function () {
 		var validatable = $("#view").kendoValidator().data("kendoValidator");
		var viewModel = {
 			LogOn: function () {
			var userName = this.get("UserName");
 			var password = this.get("Password");
 				if (validatable.validate()) {
				//What should be done here in order to send username and password?
				}
			}
		};
		kendo.bind($("#view"), viewModel);
	});
 </script>

C# code: how this part should look like?

public class AccountController : Controller
{
	[HttpPost]
	public ActionResult LogOn(LogOnModel modelstring returnUrl)
	{
		if (ModelState.IsValid)
		{
			if (Membership.ValidateUser(model.UserNamemodel.Password))
			{
				FormsAuthentication.SetAuthCookie(model.UserNamemodel.RememberMe);
				if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
					&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
				{
					return Redirect(returnUrl);
				}
				else
				{
					return RedirectToAction("Index""Home");
				}
			}
			else
			{
				ModelState.AddModelError("""The user name or password provided is incorrect.");
			}
		}
		return View(model);
	}
}






Jan
Top achievements
Rank 1
 answered on 28 Jun 2012
1 answer
381 views
When defining filter in my views using the new helpers, the filter values come back null. Here is one example (I have few other very similar grids all producing the exact same result for me).

In this example, I am giving the filter a value coming from the ViewBag.StatusID, however hard-coding a specific value (1) produces the same null value.

View

@(Html.Kendo().Grid<Mobooka.Models.Campaign>()
	.Name("CampaignsGrid")
	.Columns(columns =>
	{
		columns.Bound(o => o.CampaignID).Title("ID").Width(80);
		columns.Bound(o => o.Offer.OfferName).Title("Offer");
		columns.Bound(o => o.Offer.Advertiser.Company.CompanyName).Title("Advertiser").Width(180);
		columns.Bound(o => o.Status.StatusName).Title("Status").Width(100);
	})
	.DataSource(dataSource => dataSource
		.Ajax()
		.Read(read => read.Action("GetCampaigns""Home"))
		.Filter(filter => filter.Add(f => f.StatusID).Equals(ViewBag.StatusID))
.PageSize(25) .ServerOperation(true) ) .Filterable(filtering => filtering .Enabled(true) ) .Pageable(paging => paging .Enabled(true) .Info(true) .PageSizes(false) .Refresh(true) ) .Scrollable(scrolling => scrolling .Enabled(true) .Height(560) .Virtual(true) ) .Sortable(sorting => sorting .Enabled(true) .AllowUnsort(true) .SortMode(GridSortMode.SingleColumn) ) )

Controller

public ActionResult Index()
{
	ViewBag.StatusID = (int)Enumerations.Status.Pending; 
	return View();
}
...
public JsonResult GetCampaigns([DataSourceRequestDataSourceRequest request)
{
	IEnumerable<Campaign> campaigns = db.Campaigns....;
	return new JsonNetResult(campaigns.ToDataSourceResult(request));
}

Request

  1. Request URL:
    http://dashboard.mobooka.local/Admin/Home/GetCampaigns
  2. Request Method:
    POST
  3. Status Code:
    500 Internal Server Error
  4. Request Headersview source
    1. Accept:
      */*
    2. Accept-Charset:
      ISO-8859-1,utf-8;q=0.7,*;q=0.3
    3. Accept-Encoding:
      gzip,deflate,sdch
    4. Accept-Language:
      en-US,en;q=0.8
    5. Cache-Control:
      max-age=0
    6. Connection:
      keep-alive
    7. Content-Length:
      55
    8. Content-Type:
      application/x-www-form-urlencoded
    9. Cookie:
      ASP.NET_SessionId=nrwg2rrgsl1mpskv4yd40na0; .MOBOOKAXAUTH=F8959A12603B131542EB99BCA073D828E64DB8EAA2BF0832D9C12107ED7D453AA9344DEE6AF10ADC966E1C1E50C517378805C2A50D12447FDCEDE5BFB6D69852444068BA6FAE7EFB5B198516494F4223D3221681FF0859D795FDDA70092F184F9C403A49B18BA57BF9F7F248A623F06E40915409CDAA83303B34536978E15A747FA3A47DE6A1D6932845ACDA4461ADC98A05F0EB; MOBOOKASESSION=Name=Mobooka&Type=Employee&A=0&E=7&P=0&U=21; .ASPXROLES=qK_xf5Puh7ahlJTQbCqrdo9FbtqU1d8cQFTVb-CRXFaFk8I1TtnjXrhJMmgwWFii2c24xHu2RAODRoKTCmFc8q0DP9nTavMKWK1XAwbEwtaGeHlg3SHcIjMS8UETV4lu8nOLlc2B6Ke1uUzxKqimbH2WrQN-NvKn212PpnBv6Tw4qeIgGShmK3YMXWjwj_HQzOHx_sjw6fuUOa8RtS-sFZUa6dE-XQyJguHLAlQibYl7DWTCvrSn4Lao7VImcKku9ql_eu6iFVal0kYxnR7e7K5ixOLayyiioUIb7ocwC_xMwPTxc8bAtKe2FTDJbTXSUqrcPu-n4EsffvtjjMgRfQ9ERw7j24hTYPE97fuwO-3YUxYLF5sb9LEM4Flpdf7ppDRelxCJw-1SO84nvQ9pCmX_AfPpdVTGQ1vCrGUkq2TjAD_7Q2c9n9OZhVLlbguEKO52xqcoZ0jOCRtABa8iBv73qBEOcFhd6ju66cV2VJwpPUSzY5dedqxWcQmMS0vKaSPhRALNdJwIJS4IK0w_PsSbU4Tz035EftcE7vb80HJVKS4U0
    10. Host:
      dashboard.mobooka.local
    11. Origin:
      http://dashboard.mobooka.local
    12. Referer:
      http://dashboard.mobooka.local/Admin/Home
    13. User-Agent:
      Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
    14. X-Requested-With:
      XMLHttpRequest
  5. Form Dataview URL encoded
    1. sort:
    2. page:
      1
    3. pageSize:
      25
    4. group:
    5. filter:
      StatusID~eq~null
  6. Response Headersview source
    1. Cache-Control:
      private
    2. Content-Length:
      8506
    3. Content-Type:
      text/html; charset=utf-8
    4. Date:
      Wed, 27 Jun 2012 17:45:11 GMT
    5. Server:
      Microsoft-IIS/7.5
    6. X-AspNet-Version:
      4.0.30319
    7. X-Powered-By:
      ASP.NET
Rosen
Telerik team
 answered on 28 Jun 2012
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
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
DropDownButton
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
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?