Telerik Forums
UI for ASP.NET MVC Forum
0 answers
125 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
238 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
747 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
144 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
524 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
376 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
0 answers
218 views

.ToolBar(toolbar => {toolbar.Template(

@<text>

<div>

@foreach (var role in Model)

{

<input type="checkbox" name="roleIds" value="@role.Id"/>

@Html.Label(role.Name, new { @class = "checkbox" })

}

@item.CreateButton(new Text="New")  //it doesn't work,

</div>

</text>); })



how to change the text of the button? thank's!

xu
Top achievements
Rank 1
 asked on 28 Jun 2012
0 answers
174 views
I need to show images in panelbar items but I'm having no luck.
Please can you show code to use the template property of a panelbar item ... I have the following to start with:-
.........
.ItemDataBound
((item, product) =>


    item.
Text = product.Player.FullName;
    
item.Template .....

.....

Thanx.

 

 

 

 

 

//item.Action("Index", "Player", new {id = product.Id});

item.

 

 

 

 

 

Selected = false;

item.

 

 

 

 

 

HtmlAttributes["id"] = product.Player.Id;

}));

 

 

 

 

 

 

 

stevesuk
Top achievements
Rank 1
 asked on 28 Jun 2012
1 answer
520 views
Hey I've been trying to get the value from a dropdownlist, and cant seem to get it working. Am I doing something wrong.
The dropdown displays normally and everything and i map the event fine, but once it fires i get this javascript error when it tries to get the value:

 "Uncaught TypeError: Cannot call method 'value' of undefined" Here is my code:

                @Html.LabelFor(m => m.Country)
                @(Html.Kendo().DropDownListFor(m => m.Country)
                  .Name("CountriesDropDown")
                  .DataTextField("Name")
                  .DataValueField("CountryID")
                  .DataSource(source =>
                  {
                    source.Read(read =>
                    {
                        read.Url("/WebUI/API/Countries/");
                     });
                   })
                  .Events(e => e.Change("CountryChange"))
                  )  

<script type="text/javascript">

    var CountriesList = $("#CountriesDropDown").data("kendoDropDownList");

    function CountryChange() 
    {
        alert(CountriesList.value());
    }
    
</script>

Thanks in advance!

UPDATE:

I noticed one more strange thing, I use DropDownListFor to map the dropdown list to my model. On the server side, if I have a Name for this DropDownList defined ( .Name("CountriesDropDown") ) i doesnt catch the value of the dropdown list if I remove the name it works fine. Is this a bug, or am I missing something?




Dennis
Top achievements
Rank 1
 answered on 27 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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?