Add custom row as 1st row in grid extjs - extjs

I want to add custom row as 1st row in grid.Supose in this link
http://ngs.woc.noaa.gov/storms/scripts/ext-3.2.1/examples/grid/row-editor.html
I want to insert custom hardcorded value as first row in this grid .How to do this i dont want to do it with store.Bascially i want to add div after header and populate my string into that
Thanks

grid.getStore().insert( index, records ) will do this if you set index = 0

you can use this code:
var grid = Ext.getCmp("yourGridId").getStore()
var myArray=new Array()
myArray['id'] = '1';
myArray['value'] = 'Dummy';
var rec = new Ext.data.Record(myArray);
grid.insert(0, rec);

Related

How to change background colour of an element at index of array?

I want to create a drop down like this:
.
I have an string array as datasource of an drop down menu.I want to give background to element at 3rd index of an array.
I have tried it in doing all things possible but not able to find out any solution.
If you insert your values to list of UIButtons (let btns : [UIButton] = [btn0, btn1, btn2, btn3]), you can do that:
for i in 0..<btns.count {
if i == 2 {
btns[i].backgroundColor = .red
}
}
or just find needed UI-element and set needed color.
You need to create an array of similar size as your dataSource and this is only if you can't add a property of the color
var arr = [UIColor]()
arr = [.red,.green,.blue]
arr[2] = .orange

Qooxdoo Set Column Width to Fill Table

I have a Table with 3 columns, the left 2 are fixed-width. I am trying to make the third column fill the whole remaining table.
I have tried:
logTable.getTableColumnModel().set(2, {flex: 1});
But this did nothing to the column width.
Thanks in advance!
The default table column model does not allow that, but the Resize table column model, `qx.ui.table.columnmodel.Resize, does. You can do something like this:
var table = new qx.ui.table.Table(
tableModel, // previously defined, with 3 columns
{
// We want to handle the behavior of table column resizing
tableColumnModel : function(obj)
{
return new qx.ui.table.columnmodel.Resize(obj);
}
});
// Use the Resize table column model to allow final column to consume
// remainder of space
var tcm = table.getTableColumnModel();
var resizeBehavior = tcm.getBehavior();
resizeBehavior.setWidth(0, 50);
resizeBehavior.setWidth(1, 140);
resizeBehavior.setWidth(2, "1*");
Enjoy.
Derrell

I am trying to make a json array after getting each records from a grid. I want to add row number of grid as key of each row in json array

I am trying to make a json array after getting each records from a grid in ExtJS 3.4.0. I want to add row number of grid as key of each row in JSON array.
var selected_value = [];
for (var i = 0; i < count; i++)
{
var rec = store.getAt(i);
selected_value[i] = rec.data;
final.push({
"i":selected_value[i],
})
}
What you do there is build an array of objects with each object containing one property called i and that property has the value of the row in it.
I guess you actually just wanted to have an array with the row objects in it, right?
final.push(selected_value[i]);
This will do the job already. No need to specify an object with associative indices.
If you're grabbing all the store's entries already or at least know the range (start and end index) you could just as well skip all the manual item picking and grab a readymade array already:
final = store.getRange();
or
final = store.getRange(from, to);

Resetting single row values

I am using smart-table to display tabular data. One column of the table is editable. It is displayed and edited in an input field. Each row has a reset button which is supposed to reset edits made in the input field to the initial state.
How do I reset values of a single row (input field) when using smart-table?
Specifically what needs to be in the following function:
$scope.resetItem = function(index) {
// .....
};
I don't know about smart-table but why don't you try to get a copy of the data upfront and replace the related row with the original one?
var initialData = angular.copy(data);
$scope.data = data;
$scope.resetItem = function(index) {
$scope.data[index] = angular.copy(initialData[index]);
}

Extjs4, Summary value of a grid column that even not checked(selected)

I need to sum of grid column. but I don't know how to get all the rows even not selected one.
For only selected I do,
(controller)
var sum =0;
var grid = this.getMyGrid().getSelectionModel.getSelection();
Ext.each(grid,function(item)){
sum += item.data.qty;
}
but How should I do to get grid data that include not selected row too?
Thank you!
this.myGrid().store.each(function() {
...
})

Resources