dgrid sorting based on "get" function - dojo

I have grid with columns with get method (an optional function that, given a data item, will return the value to render in the cell). I want to use values of this function for sorting purpose. What is the right way to do that?

No, It is not possible. The sorting is done on the data in Store/Collection. whereas, the get method is related to the particular column of the grid and is called while rendering. Sorting is done before the rendering of grid.
You probably would want to add a new property to the data/store with the values in the get function. apply sort on that property.

Related

Make a custom field as a range - like "Price" is as default in Bigcommerce

Hi I am new in Bigcommerce can I make any custom field or field as a Range and filter data base on that range.
Depending on what functionality you're needing from this custom field, you may be able to use it for the 'price range'. The value type is string, so this does not accept an array of multiple values, you can see this in our API reference documentation. If you're just needing to use custom fields to render the text on a template or so, this could work, but if you're needing more functionality from it, it'd be best to use something else.

Is it possible to subtract the number of a particular class from the page count?

I'm very new to Vue and looking for some help. I would like to perform a calculation where a number of a particular class name (showClosed) can be subtracted from the results count. Is this even possible?
I get how many records are returned using this code below
resultCount() {
return Object.keys(this.results).length;
},
This returns all records including the ones which are 'hidden' using CSS.
The problem I have is I want the 'count' to change depending on whether the expired items are displayed or not. The hidden items all have a class of 'hidden' so I wondered if I could subtract the items with the class hidden from the overall count. I'm sure there is a better way, I just don't know what it is. Any help is appreciated.
I'd do it like this, assuming that items that have a deletedAt that is not null or undefined are supposed to be hidden. It's generally easier to work from a data perspective, rather than setting the CSS class first and then trying to get data information from which CSS class is set again:
computed: {
visibleResultsCount() {
const hiddenItems = this.result.filter(x => x.deletedAt != undefined) // this callback function is assumed for my case, and should be the same as the one you use to check if you should hide with CSS.
return Object.keys(this.result).length - Object.keys(hiddenItems).length;
}
Of course you could also filter on visible items instead and get the length from that. The main takeaway is to compute with the data itself rather than trying to count elements with a CSS class.

Check whether the given object is a list?

How can we check whether the given object is a list or other type
in velocity. In that list i have another list which i need to iterate again.
I also have another data in the parent list which i want to print while iterating parent list. But the problem is the child list object also get printing with actual data. So i want to print the data by checking whether its list or not. Any help is much appreciated.
Before you get any remarks on using too much logic in templates, try this reflection based approach :
velocity (test instanceof)

extjs4 - get itemselector label value

Looking at the extjs4 documentation for the itemselector, theres a method getValue() that returns the valueField on an array, i would like to know if there is a method that gets the displayField of the value.
Thanks again
There is no such thing. You would need to write your own, or look up item by it's value and get displayField from it. Considering your last question I think you really need to extend standard ItemSelector and have your own ItemSelectorEx.

How to use GtkTreeView correctly

I am using a TreeView with a ListStore as model. When the user clicks on a row I want to take some action but not using the values in the cells, but using the data I created the row from...
Currently I have the TreeView, the TreeModel (ListStore) and my own data (which I ironically call model)..
So the Questions are:
Is it "right" to have a model - an object representation of the data I want to display and fill a ListStore with that data to display in a TreeView, or would it be better to implement an own version of TreeModel (wrapping my data-model) to display the data?
And also:
If someone double-clicks in a row I can get the RowActivated event (using C#/Gtk#) which provides a Path to the activated row. With that I can get a TreeIter and using that I can get the value of a cell. But what is the best practice to find the data object from which the row was constructed in the first place?\
(Somehow this question got me to the first one - by thinking would getting the data object more easy if I tried to implement my own TreeModel...)
It's quite awkward/difficult to implement TreeModel, so most people simply synch the data from their "real" model into a TreeStore or ListStore.
The columns in the store do not have to match the columns in the view in any way. For example, you can have a column that contains your real managed data objects.
When you add a cellrenderer to a TreeView (visual) column, you can add mappings between its properties and the columns of the store. For example, you could map one store column to the font of a text cellrenderer, and another store column to the text property of the same cellrenderer. Each time the cellrenderer is used to render a particular cell, the mappings will be used to retrieve the values from the store and apply them to the properties of the renderer before it renders.
Here's an example of a mapping:
treeView.AppendColumn ("Title", renderer, "text", 0, "editable", 4);
This maps store column 0 to the renderer's text GTK property and maps store column 4 to the editable property. For GTK property names you can check the GTK docs. Note that the example above uses a convenience method that adds a column, adds a renderer to it and add an arbitrary number of mapping via params. To add mappings directly to a column, for example a column with multiple renderers, pack the renderers into the column then use TreeViewColumn.AddAttribute or TreeViewColumn.SetAttributes.
You can also set up a custom data function that will be used instead of mappings. This allows you to set the properties of the renderer directly, given a TreeIter and the store - so, if all the data you want to display is trivially derived from your real data objects, you could even have your store only contain a single column of these objects, and use data funcs for all the view columns.
Here's an example of a data func that does exactly what the mapping example above does:
treeColumn.SetCellDataFunc (renderer, delegate (TreeViewColumn col,
CellRenderer cell, TreeModel model, TreeIter iter)
{
var textCell = (CellRendererText) cell;
textCell.Text = (string) model.GetValue (iter, 0);
textCell.Editable = (bool) model.GetValue (iter, 4);
});
Obviously data functions are much more powerful because they enable you not only to use properties of more complex GTK objects, but also to implement more complex display logic - for example, lazily processing derived values only when the cell is actually rendered.