This is a migrated thread and some comments may be shown as answers.

Grid MVVM data-columns, can we bind this to a source?

9 Answers 439 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 23 Mar 2012, 10:10 AM
I've got a bit of a scenario, I'm loving the fact you can bind a full DataSource to a grid now, but the data-columns section of it is what's troubling me.

Currently, I have
data-columns='[{"field": "ID"}]'

in which works fine, but I'm wanting a *lot* of more intense functionality than that, in which has to be done on one line in HTML otherwise the templates break in Kendo. An example of this is just one row (I have 10):

{ field: "id", title: "Actions", template: "<span class='k-icon k-arrow-next'></span> <span class='k-icon k-delete deleteLink'></span>", width: 60, filterable: false, sortable: false },

What I was looking for was something like data-columns="source: dataColumns" but this doesn't seem to work. I'd settle for being able to do the data-columns="" code on multiple lines on my HTML document. Right now, on one line, it's completely unreadable.

I'm surprised more people aren't asking how to do this, unless I'm missing something?

9 Answers, 1 is accepted

Sort by
0
Yavuz
Top achievements
Rank 1
answered on 27 Mar 2012, 08:57 PM
We're looking for the same thing - does anyone have any ideas?

We are just starting to use the declarative syntax for the grids and our simple prototype with 5 columns is difficult to read/debug.  What we do is copy the string to a .js file, edit it there using multiple lines, then "stringify" it and copy it back to the html document.

This is our current data-columns attribute for our demo grid (this is all on one line in the html document):

data-columns='[{"field":"OrderID","title":"Order Id","filterable":"false", "template":"<a href=\"##\" class=\"cmc-grid-details-popup\">#=OrderID#</a>"},"Freight", {"field": "OrderDate","title": "Order Date","width": "100","format": "{0:MM/dd/yyyy}"}, {"field": "ShipName","title": "Ship Name","width": "200"}, {"field": "ShipCity","title": "Ship City"}]'
0
Atanas Korchev
Telerik team
answered on 28 Mar 2012, 01:35 PM
Hi,

 It seems that multiline JSON is not recognized and parsed. We will implement that for the next official release.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alvaro
Top achievements
Rank 1
answered on 23 May 2012, 06:02 AM
From the release notes, this was fixed on 2012.1.515.

But if I can't just bind the data-columns to something in my VM, I still think it's weird to have all that stuff on my HTML. 

I have found a nice way to keep the columns definitions on my JS and still use MVVM binding.

http://jsfiddle.net/aoliveira/NKxYR/5/

Thanks, 

Alvaro Oliveira.
0
John
Top achievements
Rank 1
answered on 19 Oct 2012, 10:23 AM
Hi Atanas,

"filterable":"false" is still ignored. Can you confirm that it has made it into a production release?
0
Faisal
Top achievements
Rank 1
answered on 12 Nov 2012, 10:17 AM
@Alvaro your provided fiddle was not working. So I have fixed it with also some little improvements:

The working example is at following link:
http://jsfiddle.net/NKxYR/16/
0
Cory
Top achievements
Rank 1
answered on 12 Oct 2014, 05:13 PM
What is Telerik's stance on adding more MVVM bindings to the Grid? Having only events, source, and visible bindings available is pretty limiting and has the potential to force some pretty verbose JSON into HTML as Chris mentions. Considering the age of this post it doesn't seem like a columns binding has been considered.

Now that AngularJS support is included and provides a clean way to configure the grid, I'm wondering if MVVM enhancements will taper off. It'd be nice if Telerik could provide some guidance here so we know whether MVVM will continue to be enhanced or if we should be looking toward migrating pieces to Angular.
0
Atanas Korchev
Telerik team
answered on 14 Oct 2014, 06:13 AM
Hello,

Adding more MVVM bindings for the grid isn't in our immediate plans. Please open a new feedback item so we can track the user interest in this feature and prioritize it against similar items.
 
Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Oscar
Top achievements
Rank 1
answered on 19 Oct 2017, 10:49 AM

Hello kendo team:

Three years later... Any advance on this?

Kind regards

0
Alex Hajigeorgieva
Telerik team
answered on 24 Oct 2017, 05:57 AM
Hi, Oscar,

This forum thread is quite outdated and there are some MVVM features which were added since then.

You can check the Kendo UI UserVoice portal for some items that were since voted up and implemented here:

http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback/category/170280-grid?query=mvvm%20grid

Can you let me know if there is anything in particular that you are after so I can provide you with a more specific answer?  

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
MVVM
Asked by
Chris
Top achievements
Rank 1
Answers by
Yavuz
Top achievements
Rank 1
Atanas Korchev
Telerik team
Alvaro
Top achievements
Rank 1
John
Top achievements
Rank 1
Faisal
Top achievements
Rank 1
Cory
Top achievements
Rank 1
Oscar
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or