Telerik Forums
UI for ASP.NET MVC Forum
1 answer
274 views

I am trying to use the grid with a colorpicker to set a colorcode property on my model and even so the column is bound, I can never see the updated code when the model is sent to the controller.  I am using the standard in line editing function of the grid. (which manages to update teh model for simple properties.

CSHTML

@(Html.Kendo().Grid<Tetral.Services.Entities.AllocationPortfolioEntity>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.ColourCode).Title("Colour").Width("84px").ClientTemplate("<span style='display: inline-block; width: 100%; height: 100%; background-color: #= ColourCode #'>&nbsp;</span>");
            columns.Command(m =>
            {
                m.Edit();
                m.Destroy();
            }).Width(260);    

        })
        .HtmlAttributes(new { style = "height:850px;width:100%" })
        .BindTo(@Model)
        .Scrollable(scr => scr.Enabled(true))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(m => m.Id(p => p.Id))
            .Create(update => update.Action("AllocationPortfolioInsert", "DataManagement"))
            .Update(update => update.Action("AllocationPortfolioUpdate", "DataManagement"))
            .Destroy(update => update.Action("AllocationPortfolioDelete", "DataManagement"))
        )   

 

TEMPLATE

@model string
@(Html.Kendo().ColorPickerFor(m => m)
    //.Palette(ColorPickerPalette.Basic)
    .Name("ColourPicker")
    .Events(e => e.Change("colourPickerChange"))
)

 

MODEL

    private string colourCode;
        [UIHint("ColourPicker")]
        public string ColourCode
        {
            get { return colourCode; }
            set { this.colourCode = newValue;}
        }

Karl
Top achievements
Rank 1
 answered on 25 Aug 2015
1 answer
985 views

The control manages to bind and show the value from my model, but when I submit the form, the model in my controller does not show the updated value from the editor.

 

I have tried using a normal @Html.EditorFor() and this works as expected. (ie I see the updated value)

 

 @model GeneralDisclosureEntity

@using (Html.BeginForm("GeneralDisclosureTextUpdate", "DataManagement", FormMethod.Post, new { enctype = "multipart/form-data" }))
{    

    <div hidden="hidden">
        @Html.EditorForModel()
    </div>
    
            
    @(Html.Kendo().EditorFor(m => m.HTML)
          .Name("Content")
          .HtmlAttributes(new { style = "width:100%;height:440px" })
          .Encode(false)
          .Tools(t => t.Clear()
              .Bold()
              .Italic()
              .Underline()
              .Strikethrough()
              .JustifyLeft()
              .JustifyCenter()
              .JustifyRight()
              .JustifyFull()
              .InsertUnorderedList()
              .InsertOrderedList()
              .Indent()
              .Outdent())
    )

    <br />

  <button id="btnSubmit3" type="submit" style="float:right")>Save Text</button>
    
}

Alexander Popov
Telerik team
 answered on 25 Aug 2015
2 answers
1.4K+ views

Hi There

I've been trying to get this right, and none of the demos or forums posts appear to really give me a clear answer.

I'm trying to populate a dropdownlist from a related table (Foreign Key), and I'm getting a "Value cannot be null" error.

 

Here's the scenario:

I have a Courses and Cities table, defined like this,

public class City
  {
      [Key]
      [ScaffoldColumn(false)]
      public int CityId { get; set; }
 
      [Required]
      [DisplayName("City Name")]
      public string CityName { get; set; }
 
      public virtual ICollection<Course> Courses { get; set; }
  }

and this:

public class Course
  {
      [Key][ScaffoldColumn(false)]
      public int CourseId { get; set; }
 
      [Required]
      public string CourseName { get; set; }
 
      [ForeignKey("City")]
      [UIHint("GridForeignKey")]
      public int CityId { get; set; }
      public virtual City City { get; set; }
 
      [Required]
      [DisplayName("Course Rating")]
      [Range(0, 10)]
      public double CourseRating { get; set; }
 
      [Required]
      [DisplayName("Course Par")]
      public double CoursePar { get; set; }
 
      [DisplayName("Course Map Co-ords")]
      public string CourseMap { get; set; }
 
      [DisplayName("Course Notes")]
      public string CourseNotes { get; set; }
 
      public virtual ICollection<GolfRound> GolfRounds { get; set; }
 
 
  }

So, clearly it's just a Golf Score app I'm using to help me learn.

 I've scaffolded the Controller and Views using Kendo Scaffolder, and ended up with this:

public class CourseController : Controller
  {
      private GolfContext db = new GolfContext();
 
      public ActionResult Index()
      {
          return View();
      }
 
      public ActionResult Courses_Read([DataSourceRequest]DataSourceRequest request)
      {
          IQueryable<Course> courses = db.Courses;
          DataSourceResult result = courses.ToDataSourceResult(request, course => new
          {
              CourseId = course.CourseId,
              CourseName = course.CourseName,
              CourseRating = course.CourseRating,
              CoursePar = course.CoursePar,
              CourseMap = course.CourseMap,
              CourseNotes = course.CourseNotes
          });
 
          return Json(result);
      }
 
      [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult Courses_Create([DataSourceRequest]DataSourceRequest request, Course course)
      {
          if (ModelState.IsValid)
          {
              var entity = new Course
              {
                  CourseName = course.CourseName,
                  CourseRating = course.CourseRating,
                  CoursePar = course.CoursePar,
                  CourseMap = course.CourseMap,
                  CourseNotes = course.CourseNotes
              };
 
              db.Courses.Add(entity);
              db.SaveChanges();
              course.CourseId = entity.CourseId;
          }
 
          return Json(new[] { course }.ToDataSourceResult(request, ModelState));
      }
 
      [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult Courses_Update([DataSourceRequest]DataSourceRequest request, Course course)
      {
          if (ModelState.IsValid)
          {
              var entity = new Course
              {
                  CourseId = course.CourseId,
                  CourseName = course.CourseName,
                  CourseRating = course.CourseRating,
                  CoursePar = course.CoursePar,
                  CourseMap = course.CourseMap,
                  CourseNotes = course.CourseNotes
              };
 
              db.Courses.Attach(entity);
              db.Entry(entity).State = EntityState.Modified;
              db.SaveChanges();
          }
 
          return Json(new[] { course }.ToDataSourceResult(request, ModelState));
      }

 

and for the View:


@(Html.Kendo().Grid<GolfScoreMVC.Models.Course>()
      .Name("grid")
      .Columns(columns =>
      {
          columns.Bound(c => c.CourseName);
          columns.Bound(c => c.CourseRating);
          columns.Bound(c => c.CoursePar);
          columns.Bound(c => c.CourseMap);
          columns.Bound(c => c.CourseNotes);
          columns.ForeignKey(c => c.City, ( System.Collections.IEnumerable ) ViewData["Cities"], "CityId", "CityName");
          columns.Command(command => { command.Edit(); command.Destroy(); }).Width(180);
      })
      .ToolBar(toolbar =>
      {
          toolbar.Create();
      })
      .Editable(editable => editable.Mode(GridEditMode.PopUp))
      .Pageable()
      .Sortable(sortable =>
      {
          sortable.SortMode(GridSortMode.SingleColumn);
      })
      .Filterable()
      .Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .Model(model => model.Id(p => p.CourseId))
          .Read(read => read.Action("Courses_Read", "Course"))
          .Create(create => create.Action("Courses_Create", "Course"))
          .Update(update => update.Action("Courses_Update", "Course"))
          .Destroy(destroy => destroy.Action("Courses_Destroy", "Course"))
      )
)

Now, initially the CityId column was not scaffolded at all, but in the Create popup, I got a CityId input field.

I added the "columns.ForeignKey(c => c.City, ( System.Collections.IEnumerable ) ViewData["Cities"], "CityId", "CityName");" part to try and produce a dropdownlist, but I'm not getting it right.

 

I'm using the default GridForeignKey template template file, and when rendering this, is where the error comes in.

 Please help me. The standard demo here confuses me even more.

Am I supposed to create a list of the Cities first, like this?

private GolfContext db = new GolfContext();
 
      public ActionResult Index()
      {
          IList<City> myCities = db.Cities.ToList();
 
          ViewData["Cities"] = myCities;
 
 
          return View();
      }

That doesn't work either. I'm clearly missing some obvious and simple step.

 

Regards

JohannS

 

 

 

 

Boyan Dimitrov
Telerik team
 answered on 25 Aug 2015
2 answers
45 views

I have a very basic model bound grid with edit and destroy commands.

 When the grid is in Edit mode, I press the cancel button and I expect the row to stay the same as before, however the grid deletes the row?  I have verified that it is not invoking any destroy methods

 

Karl
Top achievements
Rank 1
 answered on 24 Aug 2015
2 answers
846 views

I have a problem with too small X button to close a modal window when my web site is viewed on tablet computers. 

Using KendoUI with MVC. I have a window like this:

@(Html.Kendo().Window().Name("​mywindow").Title("​My very own Window Title text")
.Content("Loading...").Iframe(true).Width(600).Height(300).Visible(false).Modal(true)

)

What I want to do is make the title text and especially the X to close the window about 2x bigger to make it easier to use on tabled computers. I this possible? If so, how?

Iliana Dyankova
Telerik team
 answered on 24 Aug 2015
3 answers
222 views

Hi.

Is it possible to open detail template for a grid in windows? not in child grid.

May be it is custom command for grid's row, but not sure in how do that.

Виталий
Top achievements
Rank 1
 answered on 24 Aug 2015
2 answers
146 views
Im trying to add MenuButtons to a Menubutton (ie a subitem), but cant find any documentation of who this can be done
Alexander Valchev
Telerik team
 answered on 24 Aug 2015
1 answer
94 views

How do you set focus for the Html.Kendo().MultiSelectFor in javascript?

 

Konstantin Dikov
Telerik team
 answered on 24 Aug 2015
1 answer
97 views

How do you set focus to the Html.Kendo().DatePickerFor in javascript?

 

Konstantin Dikov
Telerik team
 answered on 24 Aug 2015
0 answers
104 views
HI

Why there have any full official report projects for demo (not .trdx only) ?

There have the online-help for telerik reporting onyly :
http://www.telerik.com/help/reporting/programmatic-creating-report.html

but there still have NO any step by step report demo :
http://www.telerik.com/help/reporting/programmatic-creating-report.html
Need Report Library first ??

NO FULL DEMOS FOR Telerik Reporting
Telerik\UI for ASP.NET MVC Q2 2015 SP1\Open Sample ASP.NET MVC Web Site in Visual Studio 2013 - UI for ASP.NET MVC
NO FULL DEMOS FOR Telerik Reporting
Telerik\UI for ASP.NET AJAX Q2 2015 SP1\Open Sample Web Site in Visual Studio - UI for ASP.NET AJAX
NO FULL DEMOS FOR Telerik Reporting
Telerik\UI for WinForms Q2 2015 SP1\Examples\C# for Visual Studio 2010\Open C# Demo Application in Visual Studio - UI for WinForms
 
Telerik is perfect but NO FULL DEMOS FOR Telerik Reporting (MVC, etc),
so Telerik Reporting becomes very hard to start for report implementation.

Visual Studio 2015 
ASP.NET 4.6
ASP.NET MVC 5

Best regards

Chris
Chris
Top achievements
Rank 1
 asked on 24 Aug 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
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
DateTimePicker
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?