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

Hello,

I have a kendo grid in my MVC application.  I have a viewmodel that shows related data in the grid, when the user edits a row using inline editing I need it to update the database via the viewmodel.  How is this done?

My grid code

@(Html.Kendo().Grid<Multiple_Table_Post.ViewModels.MultiPostViewModel>()
          .Name("Grid")
          .Columns(columns =>
              {
                  columns.Bound(c => c.id).Title("ID");
                  columns.Bound(c => c.parent_id).Title("PID");
                  columns.Bound(c => c.vessel_name).Title("Name")
                  .ClientTemplate("<a href='" + Url.Action("Details", "Vessels") + "/#=parent_id#'" + ">#=vessel_name#</a>");
                  columns.Bound(c => c.vessel_location).Title("Location");
                  columns.Bound(c => c.vessel_mmsi).Title("MMSI");
                  columns.Bound(c => c.vessel_bhp).Title("BHP");
                  columns.Bound(c => c.vessel_omid).Title("OMID");
                  columns.Command(command =>
                  {
                      command.Edit()
                          .Text("Edit")
                          .UpdateText("Update")
                          .CancelText("Cancel");
                  }).Width(110);
              }
          )
          .Pageable()
          .Editable(editable => editable.Mode(GridEditMode.InLine))          
          .DataSource(dataSource => dataSource
              .Ajax()
              .PageSize(7)
              .Read(read => read.Action("data_read", "InlineEdit"))
              .Update(update => update.Action("data_update", "InlineEdit"))
              .Sort(sort => sort.Add("id").Descending())
              .Model(model =>
              {
                  model.Id(p => p.id);
              })
               
               
          )
      )

The viewmodel

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using Multiple_Table_Post.Models;
 
namespace Multiple_Table_Post.ViewModels
{
    public class MultiPostViewModel
    {
        // #Vessel
        public int id { get; set; }
 
        [Display(Name = "Name [Vessels(table)]")]
        [Required(ErrorMessage = "Vessel name cannot be left blank")]
        public string vessel_name { get; set; }
 
        [Required(ErrorMessage = "Location cannot be left blank")]
        [Display(Name = "Location [Vessels(table)]")]
        [UIHint("LocationEditor")]
        public string vessel_location { get; set; }
 
        [Display(Name = "MMSI [Vessels(table)]")]
        public string vessel_mmsi { get; set; }
         
        // #Vessel Details
        // Without primary key ID.
        [Display(Name = "OMID [Vessels Details(table)]")]
 
        public Nullable<System.DateTime> vessel_omid { get; set; }
 
        [Display(Name = "BHP [Vessels Details(table)]")]
        [Required(ErrorMessage = "BHP cannot be left blank")]
        public Nullable<decimal> vessel_bhp { get; set; }      
 
        [Display(Name = "PID [Vessels Details(table)]")]
        public Nullable<int> parent_id { get; set; }
 
        [Display(Name = "DECK [Vessels Details(table)]")]
        public Nullable<decimal> vessel_deck { get; set; }
         
        public virtual ICollection<vessel_details> vessel_details { get; set; }
    }
}

Controll 

public ActionResult data_read([DataSourceRequest]DataSourceRequest request)
       {
           var datacontext = db.vessel_details.AsQueryable();
 
           IQueryable<MultiPostViewModel> thevessel = from c in datacontext
                                                      select new MultiPostViewModel
                                                      {
                                                          id = c.id,
                                                          parent_id = c.vessel.id,
                                                          vessel_name = c.vessel.vessel_name,
                                                          vessel_location = c.vessel.vessel_location,
                                                          vessel_mmsi = c.vessel.vessel_mmsi,
                                                          vessel_omid = c.vessel_omid,
                                                          vessel_bhp = c.vessel_bhp,
 
                                                      };
 
           DataSourceResult result = thevessel.ToDataSourceResult(request);
 
           return Json(result);
       }

Controller : UPDATE Grid Data

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult data_update([DataSourceRequest]DataSourceRequest request, VesselsViewModel vessel)
{
    if (ModelState.IsValid)
    {
        var entity = new vessel();
        entity.id = vessel.id;
        entity.vessel_name = vessel.vessel_name;
        entity.vessel_location = vessel.vessel_location;
        entity.vessel_mmsi = vessel.vessel_mmsi;               
         
  
    db.vessels.Attach(entity);
    db.Entry(entity).State=EntityState.Modified;
    db.SaveChanges();
    }
 
    return Json(new[] { vessel }.ToDataSourceResult(request, ModelState));
}
The update code is where I am stuck, how can I get this code to use my view model and update the related tables??  Anyone ever had this problem?

 

Thanks

 

Dimiter Topalov
Telerik team
 answered on 31 Mar 2016
1 answer
355 views

I have a Kendo Grid that is formatted to edit in a popup window with a custom template:

.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("MyEditor").Window(w => w.Resizable().Events(e => e.Resize("popupResize"))))

That popup edit window template ("MyTemplate") has multiple controls on it which includes a Kendo TabStrip.  One of the tabstrip items contains another Kendo Grid.  Depending on the datasource of that grid, the width and height of the popup window may change.  This may even take the edit popup window partially off the screen.

The problem is that the Resize event (which I'm subscribing to as shown above) of the grid popup window doesn't fire when the window's size changes due to changes in the content.  It only fires if the user resizes the window with their mouse.

Is there a way to know when the content width/height of a popup edit window changes so I can call the center() method on the edit popup window?

Dimiter Topalov
Telerik team
 answered on 31 Mar 2016
5 answers
665 views

The file kendo.timezones.min.js.map is missing in ASP.NET MVC Q1 2016.

Is there any where I can download it?

 

Vladimir Iliev
Telerik team
 answered on 31 Mar 2016
3 answers
489 views
when we are typing in the combo Box, it is filtering correctly, but when we are pasting the text using "control" + V or by mouse right click and paste, then the options are not filtered.
Nencho
Telerik team
 answered on 31 Mar 2016
1 answer
214 views

I posted this in the JavaScript forum three days ago and have yet to get a response. Maybe someone from Telerik will pay attention if I post it here instead.

I recently created a new project with the latest Kendo code. The project has numerous grids and most of them use filter rows. I do all my grid filtering, sorting, paging, and grouping on the server side using the DataSourceRequest object that the grid passes through the grid's data source read action. I noticed that in the latest version of Kendo, there are four new filter operations: Is Null, Is Not Null, Is Empty, and Is Not Empty. Those seem like good options to have for filtering. The problem is that, in their current form, they're unusable for server side filtering. The filters in the DataSourceRequest object are not providing the critical Member property when using any of the new operations so I have no way of knowing which columns in my database the new filters should be applied to. Can you tell me if you are aware of this issue and, if so, when you will fix it? Also, is there a way to keep those operations (or any of the others for that matter) from showing up in the list of filter operators? Thanks.

Rosen
Telerik team
 answered on 31 Mar 2016
1 answer
227 views

I've been using the demo to set up an Image and File browser for my editor.

The image browser seems to be working fine but the file browser doesn't open, I just get the standard window pop up.

I am have added the custom controller code in the same way, inherited and maintained the naming, and using the default routing for my application.

Any ideas of what could be wrong?

 

VIEW:

@(Html.Kendo().Editor()
.Name("Description")
.ImageBrowser(imageBrowser => imageBrowser
.Image("~/Content/ProjectFiles/" + (Model.RelatedProjectId > 0 ? Model.RelatedProjectId.ToString() + "/" : "") + "{0}")
.Read("Read", "ImageBrowser")
.Create("Create", "ImageBrowser")
.Destroy("Destroy", "ImageBrowser")
.Upload("Upload", "ImageBrowser")
.Thumbnail("Thumbnail", "ImageBrowser"))
.FileBrowser(fileBrowser => fileBrowser
.File("~/Content/ProjectFiles/" + (Model.RelatedProjectId > 0 ? Model.RelatedProjectId.ToString() + "/" : "") + "{0}")
.Read("Read", "FileBrowser")
.Create("Create", "FileBrowser")
.Destroy("Destroy", "FileBrowser")
.Upload("Upload", "FileBrowser"))
)

CONTROLLER

public class FileBrowserController : EditorFileBrowserController
{
private const string ContentFolderRoot = "~/Content/";
private static readonly string[] FoldersToCopy = new[] { "~/Content/shared/" };

etc....

 

 

 

 

Niko
Telerik team
 answered on 30 Mar 2016
1 answer
541 views
Does the numerictextbox support tooltip functionality?  I can't seem to find any documentation on this.
Venelin
Telerik team
 answered on 30 Mar 2016
2 answers
158 views

Is there a way to set the background color of all cells in a column across multiple pages of a grid?  I have a javascript function that sets the background color, however, as soon as I change pages, my highlighting goes away.

 

Thanks,

Matt

Matthew
Top achievements
Rank 1
 answered on 29 Mar 2016
7 answers
827 views

 

I have a grid in which one of the columns is a dropdown. I'd like to enable the Multi Filter checkboxes for this column.

How can I do this?  If I set Multi to true it just displays the usual dropdown filter menu.

 

Liesa
Top achievements
Rank 1
 answered on 29 Mar 2016
3 answers
370 views

I have a MultiSelectFor using ajax read where I return a list of SelectList Items. Some of the SelectList items have their selected property set to true. The MultiSelect does not display those items as being pre-selected.

I have attached a file showing the View and the Controller code. (in VB)

Ivan Danchev
Telerik team
 answered on 29 Mar 2016
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
Wizard
Security
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
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?