w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to implement custom controllers in Umbraco 6
Do you really mean you want a custom controller, or do you actually just want to create a form in Umbraco using MVC? If it's the latter then you need to use a surface controller ie. ensure your controller inherits from Umbraco.Web.Mvc.SurfaceController and has the suffix 'SurfaceController'. public class MySurfaceController : Umbraco.Web.Mvc.SurfaceController { public ActionResult Index() { return Content("hello world"); } } You then need to use the custom Umbraco Html helper to create your form tags: @using(Html.BeginUmbracoForm("CreateComment", "BlogPostSurface")) { // } See http://our.umbraco.org/documentation/Reference/Mvc/forms

Categories : C#

In Umbraco 6.1.1 MVC 4, how can I do a form post back to a surface controller using a model that inherits from Umbraco's RenderModel?
Ok, I've had no responses to this question but am now in a position to answer it myself. Maybe it was a fundamental oversight, but not that obvious imho, and information on the Umbraco forum etc about inheriting from RenderModel is fairly limited. Essentially the answer, as was my first instinct, is to solve the original exception "No parameterless constructor defined for this object" by providing a paramaterless constructor. The difficulty is working out what to put inside the parameterless constructor for my model, since it inherits from the Umbraco RenderModel which requires an IPublishedContent instance passed to it's constructor. Luckily while browsing around I happened across this post on the Umbraco forum: http://our.umbraco.org/forum/developers/api-questions/40754-Getting-Curre

Categories : Asp Net Mvc

How to access ViewModel using KendoUI Grid MVC
Nothing will be send to the server automatically will be available inside the action method. What I can suggest you is to send whatever you need to that action method with the help of the data function of the read configuration to send whatever you need. e.g. .DataSource(dataSource => dataSource.Ajax() .Read(read => read .Action("Read", "Home") .Data("additionalData") ) ) // -- removed for brevity <script> function additionalData() { return { userID: 42, search: $("#search").val() }; } </script>

Categories : Asp Net Mvc

Grid data formating in View or ViewModel?
Well since the VM should provide some data and the business logic, IMHO it's totally correct that the view is formating the values, because it should interpret the VMs. Additionally, the value format is the definition of how the values visual representation looks like, so... Consider, a new requirement, you should also provide the application in another culture. The data doesn't change. You only have to improve the view...

Categories : Performance

Umbraco MVC Implementation - View does not depend on Umbraco implementations
No you can't. Simply because all requests pass through a single action. In order to retrieve a path to a CMS-managed page, you need to use the node/content traversal the @Model provides. See here for more details on this. Edit To clarify, the author of the article is suggesting that the Umbraco implementation should be more in line with a traditional MVC implementation with little or no logic in the views. Therefore, any querying of node data should happen prior to the view (e.g. in the Mappers). So this is where you would have to retrieve the links. Umbraco's default MVC implementation forces all requests to go via a single action on a single controller. The author's implementation allows the requests to be shared across one controller per document type - which is better IMO. But it st

Categories : Asp Net Mvc

How do I get data out of a custom function inside a custom binding handler into the viewmodel?
$root or $parent psuedo variables are only available from within the context of data-binding. However, you could pass those values into your custom binding with something like this: //in your view data-bind="groupTree: {rootVm: $root}" //in your binding init: function (element, valueAccessor, allBindingsAccessor, viewModel) { var settings = valueAccessor(); var rootVm = settings.rootVm; //...

Categories : Knockout Js

Umbraco MediaService / Umbraco MediaItem not saving
To Save media, I found this method with MediaService. However, I think it's possible another method more refined [HttpPost] public JsonResult Upload(HttpPostedFileBase file) { IMedia mimage; // Create the media item mimage = _mediaService.CreateMedia(file.FileName, <parentId>, Constants.Conventions.MediaTypes.Image); mimage.SetValue(Constants.Conventions.Media.File, file); _mediaService.Save(mimage); return Json(new { success = true}); }

Categories : C#

Umbraco - error when using umbraco.library:NiceUrl(...)
Ok I found a solution: I added an extra check to this part: <!-- Return the url --> <xsl:if test="$i = $max"> <xsl:if test="$id != '' "> <xsl:value-of select="umbraco.library:NiceUrl($id)" /> </xsl:if> </xsl:if> this fixed my problem.

Categories : Xslt

Preferred method of adding records to custom tables in Umbraco?
There are two answers to this question: Use a framework/solution like EF; Use Contour If you haven't looked at it, Contour is an Umbraco plugin that does exactly what you need. See here for more information about Contour. However, for more control I use PetaPoco or more recently NPoco (via NuGet) and also Autofac to inject the Database (analogous to DataContext) into the constructor of my Controllers. This is super easy and if you aren't already using an IoC container like Autofac in your builds I would highly recommend looking into it. Especially if you stick with EF, as you could ensure that a single DataContext object was created and disposed for each request, making sure that you didn't have multiple contexts floating about.

Categories : Asp Net Mvc

HTTP GET to return custom model with data from external database with Umbraco MVC Surface Controller
There are a lot of questions about this and the best place to look for an authoritative approach is the Umbraco MVC documentation. However, yes you will find, if you use Html.BeginUmbracoForm(...) you will be forced into a HttpPost action. With this kind of functionality (a search form), I usually build the form manually with a GET method and have it submit a querystring to a specific node URL. <form action="@Model.Content.Url"> ... </form> On that page I include an @Html.Action("SearchResults", "TyresSearch") which itself has a model that maps to the keys in the querystring: [ChildAction] public ActionResult(TyreSearchModel model){ // Find results TyreSearchResultModel results = new Wheels.BDL.TyreBDL().GetAllTyres(); // Filter results based on submitted mo

Categories : Asp Net Mvc

Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines
If you are trying to host the blogengine site within a virtual directory of the Umbraco site, then you will have to amend the blogengine web.config to "remove" all the Umbraco-specific handlers and modules, as these will be inherited by the blogengine application, causing this exception because the application can't find the relevant DLLs in its bin folder. I recently had a similar problem and I have posted the web.config I used in the virtual directory below. Mine was a very simple web application, so obviously this will not work by itself in your blogengine app. You will need to add the relevant parts into your web.config file. Also, this was for a v6 Umbraco install in IIS7.5, so you may have to experiment a little. <?xml version="1.0"?> <configuration> <configSecti

Categories : Iis

custom component reuse with extjs4
Don't assign created objects within a configuration! Use initComponent for that! this line plugins : [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit : 1 }) ], should be placed as this.plugins = [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit : 1 }) ]; anywhere in the initComponent body, but before callParent is called Edit: to still allow override do if(!this.plugins) { this.plugins = [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit : 1 }) ]; } Edit Avoid using static id properties! The framework handle that part for you. Wrap your head around Ext.ComponentQuery instead. It will help you to find any Component you are looking for.

Categories : Extjs

Reuse Devise authentication for custom controller
This is happening because your controller is nested inside the Spree namespace, but your routes are not. If you want to extend Spree's routes, then do this: Spree::Core::Engine.routes.draw do namespace :admin do resources :workflow, :only => [:index, :show] end end

Categories : Ruby On Rails

Reuse childs from custom UIVIewController using storyboard
Keep the logic on the parentViewController and the UI Part on the child UIViewControllers. If you need to create a new UIViewController, you will create a child that will have a corresponding XIB (or get rid of XIBs and create the interface by hand).

Categories : IOS

How to reuse a custom view and place it on layout programatically
This is a good reference for creating custom controls: http://www.vogella.com/articles/AndroidCustomViews/article.html

Categories : Java

How do I add a custom web control to a ViewModel in MVC?
You can bind it as an action parameter [HttpPost] public ActionResult YourAction(YuorModel model, string fieldname) or you can retrieve it from a FormCollection [HttpPost] public ActionResult YourAction(YuorModel model, FormCollection form) { var param = form["fieldname"]; } or just add this field to the viewmodel using the field name of the control.

Categories : Asp Net

how to reuse custom form validation rules in other forms in django
Why not just subclass your other ModelForm classes that will use this validation: class MyOtherModelForm(MyModelForm): pass Then you get it all for free though inheritance.

Categories : Django

Custom Data Types containing multiple standard types in Umbraco v6
While rooting through the source for the Repeatable Custom Content Package(which I found through the question I linked to in my question above) I stumbled upon an extremely simple solution. Add the Ultimate Picker to "RepeatableCustomContent.config" Simple but I couldn't find any clue through google. Anyway hope this can help someone else.

Categories : C#

Knockout: valueAccessor vs viewModel on custom binding handlers?
The valueAccessor argument gives you access to specifically what was passed into the binding, while the viewModel argument gives you access to the entire data object at the scope. So, if someone says text: firstName valueAccessor() would give you the firstName observable/property and viewModel would give you access to the object that contains firstName.

Categories : Knockout Js

Adding Grid Serializer of a custom module into a custom product tab
you need to add new tab to Tabs block 'Namespace/Module/Block/Adminhtml/Form/Edit/Tabs.php': $product_content = $this->getLayout()->createBlock('module/adminhtml_form_edit_tab_product', 'adminform_products.grid')->toHtml(); $serialize_block = $this->getLayout()->createBlock('adminhtml/widget_grid_serializer'); $serialize_block->initSerializerBlock('adminform_products.grid', 'getSelectedProducts', 'products', 'selected_products'); $serialize_block->addColumnInputName('position'); $product_content .= $serialize_block->toHtml(); $this->addTab('associated_products', array( 'label' => Mage::helper('module')->__('Products'), 'title' => Mage::helper('module')->__('Products'), 'content' => $product_content )); The serializer is most important feature wh

Categories : Magento

Kendo-Knockout: Calling a method that changes viewmodel property from a template with data-binding inside a grid (Updated to knockout 2.3.0)
For this particular scenario you should be able to add a ko.cleanNode call in the dataBound callback. Something like: ko.bindingHandlers.kendoGrid.options.dataBound = function(data) { var body = this.element.find("tbody")[0]; if (body) { ko.cleanNode(body); ko.applyBindings(ko.dataFor(body), body); } };

Categories : Knockout Js

How do I call my viewmodel function from its view - child of viewmodel (knockout.js)
If you want to go all the way up to your root view model, then you can use $root instead of $parent. If you want to walk up the scopes, then you can use the $parents array. If I understand your structure it looks like either $root.cacheForm or $parents[1].cacheForm would work. Note that the item passed would be the "office". You can alternatively handle something like this purely on the view model side by using a computed observable to grab dependencies on all of the things that you care about. Something like this: http://www.knockmeout.net/2011/05/creating-smart-dirty-flag-in-knockoutjs.html

Categories : Javascript

knockoutjs calling function which is defined in sub-viewModel from root-viewModel
This is not working because fnTest() is not declared in the "View", but in its "data". It works using: self.views()[1].data.fnTest() See here: http://jsfiddle.net/LJBqp/

Categories : Javascript

One ViewModel containing a collection of ViewModels, different Views depending on value of ViewModel property
Don't to it in the view, instead expose different collections on your ViewModels according to what you need to filter. This can be done either as known collections, e.g. public ObservableCollection<MonitoredItemViewModel> ItemsWhereFooIsBar ... public ObservableCollection<MonitoredItemViewModel> ItemsWhereFooIsntBar ... or you could do it more generically to return filtered collections on demand public ObservableCollection<MonitoredItemViewModel> GetItems(Func<DataValue, bool> matches) { //Filter collection with return ... allItems.Where(x=>matches(x))... ; } and call via GetItems(x=>x.Foo == Bar) The problem you are going to have is when the items change and should switch from collection to collection. If you were using ReactiveUI this woul

Categories : C#

How do I update the parent viewmodel when child viewmodel is updated
There are 3 ways I can think of that would allow you to do this. The ActionService could send out some sort of notification when data changes. One easy way to do this is to use the MvvmCross Messenger plugin. This is the way the CollectABull service works in CollectionService.cs in the N+1 days of mvvmcross videos (for more info watch N=13 in http://mvvmcross.wordpress.com) This is the approach I generally use. It has low overhead, uses WeakReferences (so doesn't leak memory), it is easily extensible (any object can listen for changes), and it encourages loose coupling of the ViewModel and Model objects You could implement some kind of Refresh API on the list ViewModel and could call this from appropriate View events (e.g. ViewDidAppear, OnNavigatedTo and OnResume). I don't generally u

Categories : C#

Is it possible to subscribe to the ViewModel events from the View using ViewModel first approach?
If you are performing ViewModel-First binding you should have already used the Bootstrapper class to create the root viewmodel for your application hierarchy. In this case, you either need to bind to a property which contains a ViewModel which is located on your root VM, or you need to make the VM a Conductor and Activate one or more items within it. Example - binding other VMs as properties Your VM: public class RootViewModel : PropertyChangedBase { private SomeOtherViewModel _someOtherView; public SomeOtherViewModel SomeOtherView { get { return _someOtherView; } set { if(_someOtherView != value) { _someOtherView = value; NotifyOfPropertyChange(() => SomeOtherView); }

Categories : Wpf

Grid not updating when updating viewmodel
Remove the Datacontext Definition from your XAML file and add it in the Codebehind. Your code creates two instances of the ViewModel. You have added the ServerInfo to the instance that isn't bound to the View an therefore couldn't see the change. ViewModel public class ServerInfo_ViewModel : INotifyPropertyChanged { public ServerInfo_ViewModel() { this.Servers = new ObservableCollection<ServerInfo>(); LoadInitialServerList(); } public ObservableCollection<ServerInfo> Servers { get { return servers; } set { if(servers != value) { servers = value; OnPropertyChanged("Servers"); } } } private ObservableColl

Categories : C#

Update One ViewModel Property from another viewmodel
Communication in MVVM Light between Model<->VM<->View's are normally via the Messenger class. In short, the Messenger allows you to send a "message"(could be a string, int, pretty much any type you want) from one class to another. The receiver subscribes to receive these message(either based on type of message it wants to get or via a combination of who sends it and the type). Similarly the sender can also just send a message to a specific other class or to anyone who is subscribed to the type of the message. One of the main advantage's of the Messenger is it's based on weak dependency hence you don't have to create a strong dependency between something like VM<->View, thereby staying true to MVVM principles. It's also well documented and you should be able to get ample help in

Categories : Wpf

Only custom Y Grid AChartEngine
I added the APIs you need in SVN. You can download a version including this feature here.

Categories : Android

how to add custom sorting to ext grid
Just configure the sorters option of the store: store: { ... sorters: [{property: 'id', direction: 'ASC'}] } Or the sort method...

Categories : Javascript

Extjs create a grid feature or grid plugin that sets a tooltip for each column in the grid
In your plugins init method, you will be able to loop through the columns of the grid (the constructor and initComponent methods of the grid will have already been called at this point). That means that you can inspect each column to see if the user has setup a custom renderer. If there is none, you can put your one, and if there is one, you can chain the existing renderer with yours. EDIT Ext.define('My.Plugin', { init: function(grid) { // You may not need the scope, but if you do, this binding will // allow to preserve the scope configured in the column... var pluginRenderer = Ext.Function.bind(this.renderer, this); Ext.each(grid.query('gridcolumn'), function(col) { var renderer = col.renderer; col.renderer = renderer

Categories : Extjs

Is it possible to add custom asp.net controls in Kendo Grid?
Read this to find out more about dropdownlists in Kendo UI grids. Read this to find out more about date pickers. Read this to find out more about checkboxes. So you can solve all of these, but you will get quicker responses in the future if you do not post composite questions, you have posted several problems in the same question. People do not answer it because they do not bother to solve all your problems in a single question. Also, you might like to know that defining the column types of the grid's data model (not remember how, as my Kendo UI days are gone and I do not read my old code unless it is absolutely necessary) is a source of miracles. I hope my post was helpful to you.

Categories : Asp Net

Control for custom grid data
You may have to shell out some money to use a third party tool. I have used a product suite called Syncfusion, specifically their charts WPF controls. They have good Demos on their website and their customer service is good from my experience.

Categories : C#

Custom Paging for ASP.Net MVC Kendo Grid
Here is a custom paging solution we have implemented for Kendo ListView. With minor modification it should work for the grid. The solution consists of a custom DataSoure Object and a custom JSonResult class. The custom data source: public class MyDataSource { public object AggregateResults { get; set; } public object Data { get; set; } public object Errors { get; set; } public int Total { get; set; } } The custom ActionResult: public class JsonNetResult : ActionResult { public Encoding ContentEncoding { get; set; } public string ContentType { get; set; } public object Data { get; set; } public JsonSerializerSettings SerializerSettings { get; set; } public Formatting Formatting { get; set; } public JsonNetResult() { SerializerSetti

Categories : Asp Net Mvc

identifying custom shapes in a 2D grid
Using the ideas here and/or here (I guess using this one, the object types would be 0 and 1), one way to do it might be to try and match your own patterns against the catalog of collected objects. To take you own example, 100110100010 100100111110 111110000000 000010000000 Shapes A, B and C: (A) (B) (C) 1 1 1 111 1 11 111 or 1 111 or 1 11 or 1 11 The first collected object might be, 1 11 1 1 11111 1 => represented as a set of numbers: [(0,0),(0,1),(0,2),(1,2)..etc] (the objects need not start or include (0,0) but object bounds seem needed to calibrate the pattern matching) Testing object A against the top left of the object would match [(0,0),(0,1),(0,2),(1,2)]. After A is matched, the pr

Categories : Algorithm

Custom DataView Grid Control
You can use the DataGridView.CellFormatting event. This event occurs when a cell has to be formatted for display. Rows that are "hidden" won't have this event being called upon. Private Sub dataGridView1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) _ Handles dataGridView1.CellFormatting '----------------------------------- ' Do my magic End Sub Normally you don't have to create a custom control to do this. Just wire up the event.

Categories : Vb.Net

Property Grid Custom Editor
You need to define a class that inherits from UITypeEditor who's job will be to display Form1. This type is what goes into the EditorAttribute (not Form1). The sample here is more or less what you need to implement. Basically, you override GetEditorStyle to return UITypeEditorEditStyle.Modal and override EditValue to call IWindowsFormsEditorService.ShowDialog on an instance of your form.

Categories : C#

Custom column in MvcContrib Grid
Build the HTML with a string.Format. Something like this: c.ExistsInPatRec ? string.Format("<a href='{0}' target='_blank'>Details</a><img src='{1}' />" Url.Action(c.CaseNumber.ToString(), new { id = c.CaseNumber }), urlToImage) : Html.Label(c.CaseNumber.ToString()))

Categories : Misc

Kendo grid custom sort
I believe if you set the field property to the field you want to use for filtering/sorting, and then use a template to display another column or a formatted result, that should give you what you want. Depending if you're using MVC helpers or JavaScript or something else I could provide a sample for you.

Categories : Javascript

How to link to a custom grid with pre-applied filters?
That is not 'seesion jargon'. It's actually the filter values encoded with base64_encode. So you can generate your url like this: $filter = 'username=Jack'; $filter = base64_encode($filter) $url = Mage::helper('adminhtml')->getUrl('adminhtml/bookouts/index', array('filter'=>$filter));

Categories : Magento



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.