Does Kendo grid support scaffolding / auto generate columns - grid

I am using MVC4 and I want to be able to bind my grid to a model and have it generate the columns at run time. I have done this before with the .asp version of the control and I am new to the Kendo UI version. I read that I should not use the MVC versions from telerik since they are being obsoleted. I have looked for an example of how to do this without luck. (both on their site and on the google)
I do not have to use the Kendo grid control so if there is something better out there that works with MVC I would love to know that as well. There are some advanced features I will want to make use of such as the detail template eventually.
Thanks in advance for any help,
Scott

the column factory object provides this. for example this:
.Columns(col => {
col.Bound(c => c.columnname1);
col.Bound(c => c.columnname2);
col.Bound(c => c.columnname3);
col.Bound(c => c.columnname4);
})
would become this:
.Columns(col => {
col.AutoGenerate(true);
})

Related

Fluent Design in Xamarin.Forms

Fluent design by Microsoft are basically guidelines to design apps but they also include code snippets and tools on how to achieve them in UWP apps. A lot of tools and snippets are available for UWP but I cannot find anything for Xamarin.Forms.
How can Fluent design be implemented in Xamarin.Forms?
In my shop we use XAML for UI, you may have some luck writing fluent methods for C# UI code but I find the declarative nature of XAML to be fairly intuitive and easiest to use.
That being said you may want to explore Reactive UI for ViewModels. It's fluent in design right out of the box.
https://reactiveui.net/docs/guidelines/platform/xamarin-forms
var canExecute = this.WhenAnyValue(
x => x.UserName, x => x.Password,
(userName, password) =>
!string.IsNullOrEmpty(userName) &&
!string.IsNullOrEmpty(password));
LoadCommand = ReactiveCommand.CreateFromTask(LogOnAsync, canExecute);
LoadCommand.ThrownExceptions.Subscribe(error => { });

angular.js (or knockout.js) integration with other UI libraries?

I am going to use either knockout.js or angular.js libs (b/c of the binding support) for a web app.
My question is - how is your experience integrating these libs into existing UI libs like Dojo, jQueryUI, Ext.js, YUI,..
E.g. how is the usage of databinding suport/syntax in the UI libs? Do you have to implement something like custom binding in order to use the widget form UI lib?
For Knockout the situation is quite good. One can integrate with third-party widgets via custom bindings. Bindings API is very simple and strait-forward. All you need is to implement one or two methods (quoting Knockout docs):
ko.bindingHandlers.yourBindingName = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
// This will be called when the binding is first applied to an element
// Set up any initial state, event handlers, etc. here
},
update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
// This will be called once when the binding is first applied to an element,
// and again whenever the associated observable changes value.
// Update the DOM element based on the supplied values here.
}
};
Most of the time implementing single update method is sufficient. There's even a collection of ready-made bindings for jQuery UI. It doesn't cover all jQuery UI widgets but since creating custom bindings is so simple you can implement your own bindings as you see need.
As for Angular JS the situation is more difficult. You can create a custom binding as a part of your own Directive. Directives API requires you to write much more code. The lifecycle of directives is quite complex, too. So, they would take quite a bit of time to learn.
At the same time it lets you specify a lot of different aspects of behavior. For example you can completely rewrite the inner HTML representation of a widget via directive and use Angular templates inside. In Knockout you'd need to use jQuery for that. Unfortunately, unlike custom bindings in Knockout directives are more suitable for writing your own widgets and not for integrating with existing ones.
To summarize:
Knockout bindings are easier. Integrating with third-party widgets is easy.
Angular directives are more suitable for writing your own widgets but are more powerful at the same time.
Typically you would implement custom bindings to work with external libraries, but there are often plenty of open source efforts that have already made considerable headway. Check out
https://github.com/SteveSanderson/knockout/wiki/Bindings
If there aren't any available, implementing your own isn't terribly complicated:
http://knockoutjs.com/documentation/custom-bindings.html

MvcContrib - How to get Area into MenuBuilder ActionLink

I am using MenuBuilder with code like this:
public static MenuItem MainMenu(UrlHelper url)
{
Menu.DefaultIconDirectory = url.Content("~/Public/Images/");
Menu.DefaultDisabledClass = "disabled";
Menu.DefaultSelectedClass = "current";
return Menu.Begin(
Menu.Items("",
Menu.Action<HomeController>(p => p.Index(), "Home")
),
Menu.Items("",
Menu.Secure<HomeController>(p => p.About(), "About")
),
Menu.Items("",
Menu.Action<RegulationController>(p => p.Index(null), "Compliance")
)/* This is in the Compliance area */
).SetListClass("menu");
}
But I am also using MvcContib Areas and in the code above the final menu item is in an 'Area' called 'Compliance'.
(There are two other areas in the Mvc application and the first in the list of registered areas is called 'Legislation')
What happens is the following:
When a page is rendered (I am using the standard WebFormsViewEngine) the Urls are all rendered using the 'Legislation' area!!?
E.g. http://localhost:1337/Legislation/Home or http://localhost:1337/Legislation/Home/About
and finally http://localhost:1337/Legislation/Regulation
The first two links should not pick up the 'Legislation' area. The last menu item should be in the 'Compliance' area.
How do I prevent the erroneous Area (Legislation) being rendered on the first two links?
How do I get the MenuBuilder markup in the Site.Master to accept an 'area' attribute or get it picked up automatically from the Controller for each link?
It seems that MvcContrib MenuBuilder does not play well with Areas. In the end I took the Areas out and the problem went away.
However, I recognise there may have been some other issue in the Mvc application which may indeed have been related to the older (beta?) version of Mvc dll that MvcContrib was referencing.
So for anyone that comes across this it may indeed be a none issue.

ASP.NET MVC2 Not replacing underscores with dashes in HtmlAttributes

I've heard from a couple of different sources that when using HTML helpers in ASP.NET MVC2, one can create custom attributes with dashes in them (e.g. <a data-rowId="5">) by using an underscore in place of the dash, and when the HTML is written to the page the underscores will be replaced by dashes.
So, something like this:
<%= HtmlActionLink(Model.Name, "MyView", null, new {data_rowId = Model.id}) %>
should render as
<a data-rowId="0" href="myURL">Row Name</a>
But... it's not. I think that maybe this feature is only enabled in the MVC3 Beta preview (as it's mentioned in the MVC3 preview release notes), but this thread is about the same thing, and it's regarding MVC2.
I know I can use the other solution presented in that thread, but I'd rather not have to resort to using the dictionary if a more elegant solution exists.
Anyone know if there's something simple I can do to get this particular thing working?
Not exactly the most elegant solution but probably acceptable:
<%= Html.ActionLink(
Model.Name,
"MyView",
null,
new Dictionary<string, string> { { "data-rowId", Model.id } }
) %>
On a side note: data-rowId is a totally invalid attribute in HTML according to standard doctypes so maybe the most elegant solution would be to get rid of it :-)
System.Web.Mvc.HtmlHelper provides a static method that does what you're looking for:
<%= Html.ActionLink(
Model.Name,
"MyView",
null,
HtmlHelper.AnonymousObjectToHtmlAttributes(new { data_row_id: Model.id })
) %>
This method will will substitute underscores with hyphens - as somebody pointed out though, be sure to use all-lowercase attribute names, which are HTML5-compliant.
Consider what ASP.NET MVC is designed to do. It is designed to give you tight control over the HTML that you produce. If something is not accessible, you won't have to jump through hoops to fix it. What you are trying to do is create invalid HTML, or XHTML. Instead of trying to make HTML that is invalid simplify to just using an ID. #1 on the accessibility guidelines is that the HTML is valid for the declared type.
As long as the ID is unique within the document you will have satisfied HTML conformance--and it will make it much easier to manipulate with jQuery.
If I may, why are you trying to create invalid HTML? Or is this a proprietary XML format?
BTW, MVC 3 RC came out today.
Edit:
Playing with HTML5 features, while "shiny" and kool, are unstable. Many parts of the specification are changing as often as weekly. What is considered good now may not be good when the final spec is released. MVC 3 does have some things that will make your job more friendly, for now you have to use a dictionary.

Flex : Displaying the Advanced DataGrid data in Pages

I have a flex application where Im displaying login data using an advanced datagrid. Is it possible to show the data in this advanced datagrid, by a page wise way? if so do you have any sample coding to do this. thanks
Here's an example I think might help you: http://gurufaction.blogspot.com/2007/02/flex-datagrid-paging-example-with.html
SWF: http://develop.gurufaction.com/App.swf
MXML: http://develop.gurufaction.com/src/App.mxml
You can use the "filterFunction".
Write a custom function to filter data according on which "page" you are browsing.
Another solution is to split the original array to get several array which will be assigned according to the current page.

Resources