Extjs 4 Grid findcolumn - extjs4

I search a way in extjs 4 to find grid columns dynamic, because i wrote a function to show errors in editor grid. In version 3 i've made it over
getColumnModel().findColumnIndex(cellname);
but column model no longer exists, does anybody has an idea?
Regards

I just had to work this out, #VoidMan was close. Need to specify the view though. For example:
If your column is configured with an itemId like this:
{
header: 'A Column',
dataIndex: 'data',
width: 70,
itemId: 'myColumnItemId'
}
You can call it like this:
grid.getView().getHeaderCt().child('#myColumnItemId')

This is something among these lines:
myGrid.headerCt.child('#column')
where #column its your column itemId. Note, use itemId and not id because columns are now Component and Component id must be unique across all your application.
Hope that helps.

take a look at Ext.grid.header.Container and Ext.view.Table.headerCt

Related

How to make ag-Grid table responsive such that headers and rows are transposed?

See the "Collapse Rows" animated example:
That's similar to what I want to achieve.
I'd like my table to be responsive using the approach of reorganizing itself such that it shows each original row transposed (but also transpose the headers and duplicate them so that they label each row).
ag-Grid seems like a phenomenal library that has countless features, so I was surprised that the docs seem not to specify how to accomplish my goal.
Unfortunately this feature is not available out of the box.
This is actually a feature request which can be found here:
https://www.ag-grid.com/ag-grid-pipeline/
AG-3142 Allow the grid to change columns for rows (transpose rows), so the grid show each row as one column, and each column as a row
To achieve this, you would have to write a function yourself to transpose the rows into one column.
You can then leverage Grid API methods to update the column and row data accordingly.
I've created a simple plunker which does this based on a button click:
function onBtnClick() {
let newColumnDefs = [{ field: 'transposed_rows' }];
let newRowData = [];
gridOptions.api.forEachNode((node) => {
let nodeDataValues = Object.values(node.data);
nodeDataValues.forEach((val) => newRowData.push({ transposed_rows: val }));
});
gridOptions.api.setColumnDefs(newColumnDefs);
gridOptions.api.setRowData(newRowData);
}

Multi Keyword search on multi-column sql

I try to make a multi-keyword search on my website.
I want to find every post who contains A AND B.
For example if I search "A B"
I should find these post:
Title: Acd Bafd
Content: zzzzzz
And also this one
Title: ddddd
Content: AtttBcccd
But not this one
Title: Attttt
Content: Bwwwww
Because the title or the content doesn't have all the keyword I'm looking for.
For now I have made this request which is working
keys = params[:search].split(' ')
Article.where((["title LIKE ? OR content LIKE ?"] * keys.size).join(' AND '), *(keys.map { |key| ["%#{key}%", "%#{key}%"] }.flatten)).where(activate: true).order(created_at: :desc)
But the AND is acting same with a OR. It show me the 3 examples I gave.
Do you think I should separate it in two request ?
RAILS 5.2
As you explain it, then title should contain A and B, or content should contain A and B.
You can try with:
Article
.where("title LIKE '%A%' AND title LIKE '%B%'")
.or(Article.where("content LIKE '%A%' AND content LIKE '%B%'"))
I'm hardcoding the values for LIKE here, maybe you can add an example of what you're using to update this.

dynamic multiple grouptext in jqgrid

I have implemented multiple grouping in jqgrid which is dynamic(can be on 1 or many columns). And I want the grouptext to have a checkbox, column name and the value.
$("#Grid").jqGrid({
...
grouping:true,
groupingView:{
...
grouptext:['<input type="checkbox" class="groupHeader"/> ColumnName: {0}']
})
This will give me grouptext in only one groupheader. But I can have grouping on several columns where the columnName is dynamic. I tried this which is not working:
var columnNames=['ABC','DEF','GHI'];
var grouptext1=['<input type="checkbox" class="groupHeader"/> columnNames: {0}']
$('#Grid').jqGrid('setGridParam',{grouptext:grouptext1})
I can change the grouptext1 according to my needs. But I need a way to bind it to the jqGrid.
How can that be done?
Note that you have a typo errr in your code. The JavaScript is case sensitive and you have write grouping text property not correct. It should be groupText instead of grouptext as you write.
If you can see, the groupingGroupBy method has a second parameter - options. That is exactley what you need. This parameter is a grouping options. Having this you can set the groupText. in a case you want like this
$("#grid").jqGrid('groupingGroupBy',
['col1','col2'],
{
groupText : [ 'checkbox for col1', 'checkbox for col2']
...
}
);

simplecart js setting column widths

I've used this site for assistance many times but never had to ask a question so finally joined...anyway, trying to set up simplecart checkout and having some trouble formatting cart output. I have my cart set to table and by default the simpleCart_items class displays the table and it's cells only as wide as they need be to fit the data. I can change this by specifying all cells(columns) as a percentage of the whole table. Unfortunately with 7 columns each only gets about 14% and this is way to much for a 1 or 2 digit quantity and not near big enough for all the characters in the item name without wrapping. What I want is a way to define a different width for each column. I have not found a way to do this even with colgroup but maybe just not doing it right. Any and all help would be appreciated!
Okay, so this may or may not help. This line is located in the simpleCart.js file. I changed it to something simple.
cartColumns : [
{ view: function(item, column){
return"<img src='"+item.get('image')+"' width='250px' height='250px'><br /><center><h3 ><span>"+item.get('name')+"</span></h3><p><a href='javascript:;' class='simpleCart_decrement'><button>-</button></a> "+item.get('quantity')+" <a href='javascript:;' class='simpleCart_increment'><button>+</button></a></p><p>$"+item.get('price')+"</p><p><a href='javascript:;' class='simpleCart_remove remove_icon'><img src='images/icon_x.png' /></a></p></center>";
},
}
],
You can change it to your own html
cartColumns : [
{ view: function(item, column){
return" YOUR HTML HERE ";
},
}
],
It MUST all be in ONE (1) LINE or else it may not work.
here are some values that are used
image = item.get('image')
name = item.get('name')
quantity = item.get('quantity')
price = item.get('price')
you can look at all the values here
http://simplecartjs.org/documentation/displaying_cart_data
but the point is that you can make a cart and display it how you want; with you own html and css. I hope this helped.

Insert the list data at end of the groupdatamodel in blackberry 10 cascades?

I have a listview with groupdatamodel, i need to insert the list data at end of the groupdatamodel, Here i have pasted the code what i have done
GroupDataModel {
id: grouplistdatamodel
},
DataSource {
id: dataSource
source: "http://myurl.com"
onDataLoaded: {
grouplistdatamodel.insertList(data); //it will insert the data at first position in listview but i need to insert the data at last position
}
}
Can anyone help me about this regards,
In GroupDataModel should not be able to insert the data at specific poisition, so i have changed the ArrayDataModel instead of GroupDataModel.
I'm thinking of two ways to achieve this.
First, you can try to play with the GroupDataModel method setSortedAscending(bool ascending).
Otherwise, you could use setSortingKeys(const QStringList &keys) and add to the data you put in the GroupDataModel a specific key used only to sort the list.