viewmodel

Accessing viewModel functions by prototype

≡放荡痞女 提交于 2020-01-05 06:59:38
问题 I am attempting to create a generic Container for my viewModels so common methods can be applied a variety of objects without specific knowledge ot the viewModel. The container and contained object would look like this: var containedViewModel = function() { var self = this; self.id = ko.observable(); ... self.doSomething = function() { alert('here'); }; } var ContainerModel = function(cRoot, cModel, cName) { var self = this; self.rootModel = cRoot; // Root view model self.viewName = cName; //

asp mvc list product details in view using View Model

孤街浪徒 提交于 2020-01-03 18:57:10
问题 I am trying to list single product details in a view. The product specification changes dynamically because specifications are added row-wise in table, which means we can add huge number of specifications for each product (as done in ecommerce sites). Right now I am able to meet the requirement using ViewBag , but I am deciding to use ViewModel as a better practice. Model class: // Product: public partial class ProductTable { public ProductTable() { this.SpecificationsTable = new HashSet

Validation of nested models in view model in ASP.Net MVC

不羁的心 提交于 2020-01-03 18:34:11
问题 I have an application with a Company model. The Company model has a navigation property to an Address model (one-to-one relationship): Company.cs public class Company { public int CompanyID { get; set; } public string Name { get; set; } // Snip... public virtual Address Address { get; set; } } I've created a view model to handle the edit, detail, and create actions: CompanyViewModel.cs public class CompanyViewModel { public int CompanyID { get; set; } [Required] [StringLength(75, ErrorMessage

Why aren't file uploads binding to my viewmodel?

吃可爱长大的小学妹 提交于 2020-01-03 06:01:11
问题 I'm trying to bind file uploads to a ViewModel (as demonstrated in this post). But I can't get the files to bind to the Files property on the ViewModel. Please see the code below. What am I doing wrong? (Edit for clarity - I'd like the uploads to bind to the VM, not have them as an Action parameter.) ViewModel public class PrimaryImageUploadViewModel { public PrimaryImageUploadViewModel() { } public HttpPostedFileBase[] Files { get; set; } public string Title { get; set; } } Action [HttpPost]

Automapper: How to not repeat mapping config from complex type to base class

蹲街弑〆低调 提交于 2020-01-02 19:25:19
问题 I have a bunch of DTO classes that inherit from this CardBase : // base class public class CardBase { public int TransId {get; set; } public string UserId { get; set; } public int Shift { get; set; } } // one of the concrete classes public class SetNewCardSettings : CardBase { // specific properties ... } In my MVC project I have a bunch of view models with a AuditVm complex type that has the same properties of CardBase : public class AuditVm { public int TransId {get; set; } public string

ExtJs 5 grid store/viewmodel binding: Cannot modify ext-empty-store

最后都变了- 提交于 2020-01-02 12:18:11
问题 I'm pulling my hair out on this one... I have a view with some grids, a store and a viewModel. I need different filtered versions of the store in different grids, so I'm trying to bind each filtered store to a grid. Now I can't even get a store to load in a grid in the first place... Here's what my code looks like: Store: Ext.define('My.store.Admin.Kinder', { extend: 'Ext.data.Store', model: 'My.model.Kind', storeId: 'adminKinderStore', alias: 'store.adminKinder', proxy: { type: 'ajax',

MVVM- Trigger Storyboard in the View Model in Silverlight

元气小坏坏 提交于 2020-01-02 08:54:34
问题 I have a couple of Storyboards in my view that I would like to trigger from the ViewModel if possible. Is there a simple way or elegant way of doing this. Here is what I am trying to do. Person Clicks on a Button-->RelayCommand (In the ViewModel), the Relay Command should then play the storyboard. Also one more thing, I would like to also trigger the storyboard animation by itself in the ViewModel without any interaction. <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown

MVVM- Trigger Storyboard in the View Model in Silverlight

若如初见. 提交于 2020-01-02 08:53:46
问题 I have a couple of Storyboards in my view that I would like to trigger from the ViewModel if possible. Is there a simple way or elegant way of doing this. Here is what I am trying to do. Person Clicks on a Button-->RelayCommand (In the ViewModel), the Relay Command should then play the storyboard. Also one more thing, I would like to also trigger the storyboard animation by itself in the ViewModel without any interaction. <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown

“group by” proxy model

北慕城南 提交于 2020-01-02 08:28:27
问题 I have tree model with theoretically infinite depth and some property "Group". In addition to standard view, I need to show this model (and keep it in sync) in such way that each group becomes a virtual parent for all items with the same property value. What is the best way to achieve this with Qt's model/view architecture? I had solved similar problem not a long time ago via inserting additional virtual "groups" on adding/removing items to/from the model, but this method proved not to be

ASP.NET MVC ViewData and view model best practices

半城伤御伤魂 提交于 2020-01-02 05:58:10
问题 The initial situation is that I map my domain model into a presentation model. I have to display an update/create formular with textboxes and a dropdownlist. Should the viewmodel contain a list for the dropdownlist or should I pass the data for the dropdownlist by using ViewData? When should I use ViewData and when should I not use it? Shall input fields like dropdownlists have a seperate view model? 回答1: I tend to try and use ViewData as little as possible since you always need to cast