Telerik Forums
UI for ASP.NET MVC Forum
0 answers
184 views
Hi,

I have a Kendo comboboxfor on my view and the datasource comes from my model as an IEnumerable<SelectListItem>.  But running the page crashes with the subject error message.  If I change the CombBoxFor to ComboBox and attach the datasource with the dataSource method, it seem to work.  What is wrong here: 

Here is my View (code is partial):
<li>
  @Html.LabelFor( m => m.FKStatusTypeId )
  @(Html.Kendo()
          .ComboBoxFor( m => m.FKStatusTypeId )
          .BindTo( Model.StatusTypeList)
  )
</li>

and here is my Model (code is partial):
[Display( Name = "Status" )]
public int FKStatusTypeId { get; set; }
 
// use as @Html.DropDownListFor(m => m.FKBillingTypeId, Model.BillingTypeList, "--select--")
//        @Html.ValidationMessageFor(m => m.FKBillingTypeId)
 
[Display( Name = "Zip Code" )]
[Required( ErrorMessage = "Zip Code is required" )]
[ZipCodeOnly( ErrorMessage = "Zip code is not valid" )]
[ValidateZipCode( ErrorMessage = "ZipCode is not valid" )]
public string Zip5 { get; set; }
 
public SelectList ZipCities { get; set; }
 
public IEnumerable<SelectListItem> StatusTypeList
{
   get
   {
     var ctx = new PCDataEFContext();
     var sTypes = ctx.StatusTypes;
     var items = sTypes.Where( st => st.PKId > 0 )
                   .ToList()
                   .Select( st => new SelectListItem
                         {
                           Text = st.Name,
                           Value = st.PKId.ToString()
                         } );
     return items;
   }
}

What am I doing wrong here?

Babu.



Babu
Top achievements
Rank 1
 asked on 04 Oct 2012
1 answer
109 views
Basically, I have a bulleted list inside the listview, and when a user selects and item, I want it to automatically fire the create action method. And when the user deselects I want it to fire the Destroy action method
Vladimir Iliev
Telerik team
 answered on 04 Oct 2012
0 answers
107 views
Hi,

I have noticed that the "Ends with" filter does not always work when the entry matches an item in the column. I'm using client side filtering and paging.

An example of this behavior can be seen by going to the  Grid /Binding to local data online sample at http://demos.kendoui.com/web/grid/local-data.html 

In the City column set the filter "Ends with" then enter New York in the text field, 17 records are returned 4 with New York as the city, 3 with Redmond as the city and 10 with Seattle as the city.

Is there a fix and/or workaround for this issue?

Thank you,
Eric
Eric Brunswick
Top achievements
Rank 1
 asked on 03 Oct 2012
0 answers
132 views

I am using mvc4. On one of my page, it has Kendo Grid. I want to show 5 rows per page. I have no problem doing it using pure javascript, however, If I am using mvc helper. I got lost, couldn't find any samples online.

here's my javascript code.




$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "json",
serverPaging: true,
pageSize: 5,
transport: { read: { url: "Products/GetAll", dataType: "json"} },
schema: { data: "Products", total: "TotalCount" }
},
height: 400,
pageable: true,
columns: [
{ field: "ProductId", title: "ProductId" },
{ field: "ProductType", title: "ProductType" },
{ field: "Name", title: "Name" },
{ field: "Created", title: "Created" }
],
dataBound: function () {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
});
});



now if i am using mvc helper

@(Html.Kendo().Grid(Model) 
.Name("Grid")  // please help me to finish this



John
Top achievements
Rank 1
 asked on 03 Oct 2012
6 answers
1.7K+ views
MVC3 
I use in Form.cshtml
    @Html.DropDownListFor(m => m.GroupID, ViewData["GroupNameDDL"as SelectList, "-- Select one --")    

in Controller  
    ViewData["GroupNameDDL"] = _tbl68SpeciesgroupsRepository.Tbl68Speciesgroups.Select(b => new {
      Id = b.GroupID,       Name = b.GroupName}); TELERIK MVC in EditorTemplate Tbl68SpeciesgroupsForeignKey.cshtml
   @using System.Collections
   @using Telerik.Web.Mvc.UI
   @(Html.Telerik().DropDownList()
        .Name("GroupNameDDL")
        .BindTo(new SelectList((IEnumerable)ViewData["GroupNameDDL"], "ID""Name"))) 
in GridViewmodel.cs
        [Required]
        [UIHint("Tbl68SpeciesgroupsForeignKey")]
        public int? GroupId { getset; }
In Telerik I use in Form.cshtml
      columns.ForeignKey(b => b.GroupId, (IEnumerable)ViewData["GroupNameDDL"], "ID""Name");

How to implement
"-- Select one --"

    
Rudolf
Top achievements
Rank 1
 answered on 03 Oct 2012
1 answer
286 views
Hello,

I'm using MVC 4, and the KendoUI Upload widget.

.kendoUpload working fine for Controller Upload call. 
like
"public ActionResult UploadImage(HttpPostedFileBase files, string title) { }".

How can i upload files using Web-ApiController?
(ie) how can i connect "kendoUpload" to "ApiController" action?
Is it possible?

Thanks in advance!

ramesh
Top achievements
Rank 1
 answered on 03 Oct 2012
1 answer
790 views
I'm trying to create a detail popup for each line in my grid (which uses Server Binding)
I've created a custom command as follows.

columns.Command(command =>
{command.Edit();
command.Custom(

"Details").Text("Line Details").Action("Product", "Home").DataRouteValues(v => v.Add(c => c.SKU).RouteKey("selectSID"));}
);

Corresponding Controller action

public ActionResult Product(string selectSID){
var result = IProductRepository.One(p => p.SID == selectSID);
i
f (result == null)
{
return RedirectToAction("Error");}
else
return PartialView(result);
}

This all works but my Partial View is opened as a full page in the existing window, how can I open this as a popup?

I've tried using JS and kendowindow to open the popup and this does work but I can't see how to pass the SKU from the selected line in the grid so I see my error page loaded in the popup window.

This is my partial view

 @model TestKendo.Models.Product

 <fieldset>
<div class="display-field">
@Html.DisplayFor(model => model.Description)

</div
 <img src="..\120571.jpg" />
</fieldset
 <p> @Html.ActionLink("Back to List", "Order") </p>  

Any and all help appreciated, i've got this far from browsing the forums and sample apps.

Timothy
Top achievements
Rank 1
 answered on 03 Oct 2012
5 answers
682 views
Hi,

Is it possible to conditionally display the destroy button? I've messed with command.Destroy().HtmlAttributes... but it is not working.

Thanks!
David A.
Daniel
Top achievements
Rank 2
 answered on 03 Oct 2012
2 answers
219 views
Hi all, I hope someone can help on this odd problem I have.
I am performing binding against some objects called Instances.
Each Instance has a couple of strings, and another object called a Hosting Environment.
HostingEnvironment has the LocationName as a string.

So I'm using a ClientTemplate to display LocationName, while binding to the HostingEnvironment for that grid column.
I'm also using a PartialView for displaying the list of HostingEnvironment locations names in a dropdown during an edit.
That all works great, I can view and edit records.

The problem happens as soon as I click the "Create" button... it immediately throws an error:
0x800a1391 - JavaScript runtime error: 'HostingEnvironment' is undefined

When I break into the generated code, I can see that all the strings are blank (a good thing) except HostingEnvironment doesn't have a value (yes it's null)... so I guess the PartialView doesn't like that maybe?

I'm not really sure what to do...

Here's my main view.

@model IEnumerable<Core.Domain.Entities.Instance>

@(Html.Kendo().Grid(Model)
    .Name("Instances")
    .Columns(columns =>
    {
        columns.Bound(p => p.InstanceName).Title("Instance Name");
        columns.Bound(p => p.InstanceFullName).Title("Instance Full Name");
        columns.Bound(p => p.HostingEnvironment);//.Title("Hosting Environment").ClientTemplate("#: HostingEnvironment.LocationName #");
        columns.Bound(p => p.SysId);
        columns.Command(command => {command.Edit(); command.Destroy(); });
    })
    .Pageable()
    .Sortable()
    .Scrollable() 
    .Filterable()
    .ToolBar(commands => commands.Create()) 
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .DataSource(dataSource => dataSource        
        .Ajax()
        .Model(model => model.Id(p => p.SysId))
        // Configure CRUD -->
        .Create(create => create.Action("CreateNew", "Instance"))
        .Read(read => read.Action("Read", "Instance"))
        .Update(update => update.Action("Update", "Instance"))
        .Destroy(destroy => destroy.Action("Destroy", "Instance"))
        // <-- Configure CRUD        
     )
)
Jon
Top achievements
Rank 1
 answered on 03 Oct 2012
0 answers
401 views
Thought this might help, a client has a requirement for a grid to be placed in a splitter with grid in line editing at the same time in another splitter pane they want an editable version of the record shown.
The problem I had was getting kendo data binding on to the partial view this is my solution for a general binding function where the container is an html form bound to a POCO class, the model is the dataItem of a selected grid row.

function databind (container, model) {
   if (container) {
      container.find(":input:not(:button, [" + kendo.attr("role") + "=upload], [" + kendo.attr("skip") + "]), select").each(function () {
         var bindAttr = kendo.attr("bind"),
               binding = this.getAttribute(bindAttr) || "",
               bindingName = this.type === "checkbox" ? "checked:" : "value:",
               fieldName = this.name;

         if (binding.indexOf(bindingName) === -1 && fieldName) {
            binding += (binding.length ? "," : "") + bindingName + fieldName;

            $(this).attr(bindAttr, binding);
         }
      });
      kendo.bind(container, model);
   }
}

function grid_change (e) {
   var pid = this.select();
   var dataItem = this.dataItem(pid);
   var details = $('#your container for form');
   var frm = $("#your form");
   if (frm[0]) {
      databind(details, dataItem);
   }
   else {
      $.post('@Url.Action("GetPartialViewForForm","Controller")', {
         ID: dataItem.ID
      }, function (data) {
         details.empty().append(data);
         databind(details, dataItem);
         var frm = $("#your form");
         frm.submit(function (e) {
            var data = $(this).serialize();
            $.post(this.action, data, function () { });
            e.preventDefault();
         });
      });
   }
}

//Controller
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GetPartialViewForForm(int ID)
{
   //get the data
   return PartialView();
}

Timothy
Top achievements
Rank 1
 asked on 03 Oct 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
LLM Kit
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?