MVCContrib grid - sorting a custom column - asp.net-mvc

Just started learning to use the grid so please excuse me for the possibly trivial question.
How can I sort by a column that uses another table property?
For ex.
column.For(cust => cust.LinkedTable.someProperty).Sortable(true); definition results in a "Could not find a property called 'someProperty' on type MyProject.Models.Node" error (obvious - the property is actually MyProject.Models.Node.LinkedTable.someProperty)
One of my ideas was to create a helper:
column.For(cust => Helpers.ViewHelper.GetSomeProperty(cust)).Sortable(true);
This doesn't produce the error, but a column isn't getting sorted anyways.
In another words, is there any way to pass a string value to a column and make it sortable?
Should probably rewrite my sort function (just a OrderBy(...) now), but I don't really know how to start:) Any help would be appreciated!

You can do it like this:
column.For(cust => cust.LinkedTable.someProperty).SortColumnName(somePropertyID)
where somePropertyID is a attribute of table cust.

I would like to recommend you the JQuery grid
Check it out, it's very useful

Related

Can I add type information to an ActiveAdmin attributes_table?

I want to make a table essentially like the attributes_table, but with a column showing the type of each field. I haven't found anything as convenient as attributes_table(:show_types) or attibutes_table do; column :type; ....
Is there a way to add such a column to attributes_table? If so, how? If not, what's the closest alternative?
Defining a custom Arbre component would be the best way to accomplish it, but it would not be trivial. Creating a customized subclass of AttributesTable would be a good starting point. Modifying the implementations of row, and build_colgroups would be required at the minimum.
One key thing to note is the component will require a unique builder method name like attributes_table_with_types_for.

How to get a reference to a particular component in an Angular2 template?

I know that Angular2 has #ViewQuery to get a QueryList of components matching the given type. But is there a way to get a reference to a particular component in this QueryList?
Right now, the only way I can think to do this is to give the component an extra "id" field, then iterate through the QueryList and check if the identifier is the one I want, e.g.:
getComponentById(QueryList<HasIdField> queryList, String id) =>
queryList.singleWhere((component) => component.id == id);
But this seems like a common enough problem that it seems like there should be a way to do this without adding this "id" boilerplate. I know that a component can be referenced locally within a template using #, but is there a way to reference a component similarly within a class?
Currently this functionality does not exist, see here for details on why the functionality to implement a custom filter is currently on hold due to potential performance reasons.
So the way you are doing it seems to be the right way given the functionality that is available currently, but this might change as the framework is now in alpha.

Dynamic columns with c:forEach, ace:dataTable and IceSoft Wiki example

We are facing a problem with dynamic columns. We have a table where columns depend on some filters previouosly selected. When you enter the page you can select year and some other criteria, and with these values we render the table. Our problem is that columns may vary when you select different criteria, and this is a problem because c:forEach is not so much dynamic.
If you look at the example provided in IceSoft Wiki you can see something similar to what we have in our code (but our code is much more complicated):
http://www.icesoft.org/wiki/display/ICE/DataTable+Dynamic+Columns
The problem comes with this sentence:
<c:forEach items="#{backing.columns}" var="colModel">
backing.columns is static. But if you change its number of elements (in this example it makes no sense because values in "columns" List match to properties in Task class, but if you are printing a List instead of List) you have a problem, as described here:
http://drewdev.blogspot.com.es/2008/08/cforeach-with-jsf-could-ruin-your-day.html
We've tried to recreate component list when we change columns with:
component.getChildren().clear(); //component is of UIComponent type
But didn't work. Also we've tried restoring view from context in a PhaseListener, and no positive results. And we've run out of ideas.
Any idea (or solution :D) would be appreciated. And if someone need more specific code, just ask.
TIA.
PS: This question is also posted in ICEFaces Forum (http://www.icesoft.org/JForum/posts/list/0/21842.page#76787), and I will update with solution (if any) both places.
We've solved the problem, as we've been suggested at IceSoft Forum, redirecting navigation to the same page in order to get a completely new component tree. For this you need your state to be in a bean that will survive that, but since our backing beans are usually viewscoped this is not a problem. To achieve this, we've changd valueChangeListener method that was changing the list behind the c:foreach and used an action method, and in this action method we're returning null as navigation rule to get the page reload.
See more at: http://www.icesoft.org/JForum/posts/list/21842.page#sthash.sXtPazmS.dpuf

Knockoutjs native template binding and simple array of strings

I'm trying to understand native knockoutjs template binding, especially foreach binding.
Just wondering how to access current item using native bidning? With jQuery.tmpl it is possible using something like $item / $data. How to do the same using native template binding when data source is the arrays of primitives so each item has no named fields? Here is the JSFiddle with two examples, the first - using native binding where data source is array of custom objects, second one - binding to an array of strings. I'm unable get it working, looks like I'm missing something obvious?
Basically I'm trying to understand native bindings and be able refactor following example using native binding: JSFiddle: Comma separated list of checked items so I would be able keep an observable variable which represnts a comma separated list of checked items.
You can use $data to access the raw value like: http://jsfiddle.net/rniemeyer/M73S8/3/.
Here is the other fiddle updated: http://jsfiddle.net/rniemeyer/EGAH9/8/. Not sure the exact functionality that you want to support in it.
I am not sure if this is already answered from the amazing Niemeyer (thanks for all of your help in the Knockout Community!), but I made a jsFiddle to show storing the actual Person objects Selected in an observable array.
I am not sure if that is what you are trying to do, but maybe someone else is researching this looking on how to do this exact thing: bind the actual objects into an observable array, not just the ids (although, i added that too to remind me).
Example of a Checkbox List Selected Object Binding: http://jsfiddle.net/cjgaudin/Dp7Br/

Sending multiple id values to controller action; best practice?

Explanation: I have a grid with a checkbox column where users can check records they want to view details of. Each checkbox has a value of the ID of that object. I want to then pass these values to a controller action so that I can render a paged view, as it were.
Now, what I have right now is technically working, but it's ugly and something tells me there's a better way. Right now I'm creating a JSON string of the array values and passing that, so the route ends up looking like "/Products/Details/["4","5","6"]"
Now, as I said, this works and I can parse out the values in the controller, but something tells me I shouldn't have to. Am I missing something simple, or does someone know of a decent way of doing this? The number of values can be arbitrary based on what the user has selected, so I can't create a custom route (I don't think, anyway).
Thanks, all.
If you haven't read Phil Haacked - Model Binding To A List I would highly recommend starting there, it should help alot.

Resources