Remove all columns from a CellTable - gwt

I'm using a CellTable from GWT 2.1.0.M3. There are removeColumn functions, but no removeAllColumns or anything. Since "columns" is a private member of CellTable, not even my extension of CellTable can easily access it.
For now, I'm just storing the number of columns I add so I can remember to remove them all. Anyone know a better way?

I am using this way
Take count of columns of table
int count = this.getView().getTbcell().getColumnCount();
Loop through and remove first column
for(int i=0;i<count;i++){
this.getView().getTbcell().removeColumn(0);
}
Thats it we are done :-)

while (cellTable.getColumnCount() > 0) {
cellTable.removeColumn(0);
}

This might not be what your looking for but it works for me:
getCellTable().setVisibleRange(0, 0);
listViewAdapter.updateRowData(0, result);
getCellTable().setVisibleRange(0, 10);

Related

How to delete empty rows from Grid in my Form?

I use to fill my StringEdit a simple displayMethod.
This method selected to see some records from myTable and discard others , this method work well, but, in my Grid I see the empty records-rows(that would be the record discarded).
For to fill my StringEdit I used this dispaly method :
display myEXDTypeString nameFIeld()
{
MYTable mineTable;
myEXDTypeString name;
while select mineTable
where this.FieldtoUse== "Value"
name = this.NameFIeld;
return name;
}
There's a way to delete the empty rows?
In my Grid
I have a Lesf site state , I want to have the right situation:
Thanks all!
Enjoy
If you are just trying to get the Form to not display blank records then it could be as easy as setting a QueryBuildRange on the data source:
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
super();
queryBuildDataSource = this.query().dataSourceName(mineTable_ds.name());
queryBuildRange = queryBuildDataSource.addRange(fieldNum(MineTable, FieldToUse));
queryBuildRange.value('>0');
I solved my problem: the cause is the Form DataSource relation.
OuterJoin Split my Lines.
Thanks all, enjoy!

Form grid filters

I want store the filters entered on the grid, is it possible to store the filters entered on filter pane of the grid.
I want to use those filters entered in my class, please help me in this regard.
No, form queries cannot be saved as code (but such functionality could be programmed).
A form query could be passed from the form to a class, using a parmQueryRun method or similar.
See:
How to Create Queries by using the AOT
How to Create Queries by Using X++
Yes you can retrieve the filters by getting the form's queryRun's query and packing that into a container to be stored/passed/unpacked.
The form has a query, that is passed to QueryRun, then the users puts filters/dynamic joins/etc on that query that belongs to the QueryRun. So you need the modified query to store what you want from it.
void clicked()
{
Query q = salestable_ds.queryRun().query();
int i;
container c;
for (i = 1; i <= q.queryFilterCount(); i++)
{
info(strFmt("%1: %2", q.queryFilter(i).field(), q.queryFilter(i).value()));
}
// If we want to store these we can do
c = q.pack();
}
See this post http://dynamicsuser.net/forums/t/63208.aspx

Programatic CellTable sort in GWT not working

I'm using the ListDataProvider example here as a guide. The columns are sorting fine as expectd based on the provided comparators. I'm trying to programatically apply a sort as alluded to on this line from the example:
// We know that the data is sorted alphabetically by default.
table.getColumnSortList().push(nameColumn);
What this does, is it makes the cell column appear to be sorted with the carrot sort indicator. However, the underlying data isn't sorted. Is there a way to get the table to actually apply the sort progarmatically. I suppose I could use this in conjunction with actually sorting the data via Collections.sort(), but I'd like to avoid that and do it in one place.
You can apply sorting on a column programatically with little exta code. The following code snippet does that -
When ever u set data to the cellTable you have to initialize the ListHandler as below code does -
cellTable.addColumnSortHandler( createColumnSortHandler() );
private ListHandler<T> createColumnSortHandler()
{
final ListHandler<T> listHandler = new ListHandler<T>(listDataProvider.getList());
listHandler.setComparator( sortColumn, comparator );
return listHandler;
}
And when u want to fire the SortEvent execute the following code snippet -
ColumnSortInfo columnSortInfo = new ColumnSortInfo( sortColumn, sortDirection );
cellTable.getColumnSortList().push( columnSortInfo );
ColumnSortEvent.fire( cellTable, cellTable.getColumnSortList());
you have to call setData on grid again.....

How to delete value from jsarray in GWT?

i have two questions:
1) is it possible to delete any value in jsarray or only the last on with the pop method?
2) how can i remove or delete a value from jsarray? does somebody can post an example.
something like this here
public JsArray<MyObject> myObjects = JavaScriptObject.createArray().cast();
myObjects.push(new MyObject("Good"));
myObjects.push(new MyObject("morning"));
myObjects.push(new MyObject("people"));
myObjects.delete(1);
thx a lot!
Arrays in JavaScript are sparse, so you cannot, for example, remove an object from it and have all the following be moved up to lower indices (like you'd have in Java with a List for instance); at least not with some remove method.
Using only GWT Java, you can set the value at a specific index to null, but that's it.
Using JSNI, you can delete it (almost equivalent to setting it to undefined: delete myObjects[1]) or you can remove it:
public static native remove(JsArray<?> arr, int index, int count) /*-{
arr.splice(index, count);
}-*/;

Querying class on Raphael object

I have this array of rects using jQuery and Raphael:
squares = [];
for (i = 0; i < 2; ++i) {
var square = paper.rect(0 + 100*i, 0, 70, 70);
square.node.idx = i;
square.node.setAttribute('class', 'foo');
squares.push(square);
}
I can successfully query various attributes, like:
alert(squares[0].attr('x'));
or
alert(squares[0].attr('width'));
but not:
alert(squares[0].attr('class'));
Is there a special reason for which this is not valid?
Is there an (other) way to query the class attribute?
Thanks,
Adrian
Classes in SVG aren't quite the same as classes in everything else - and in Raphael, which deals with SVG and IE's VML, things get even more hairy.
First of all, they're on the page's DOM element (Raphael's output) not in the Raphael JS object itself. You'd use Raphael's .node to get the actual DOM path (e.g. with jQuery, $(squares[0].node).someJqueryFunction();) but this sort of thing is best avoided where possible for the above reasons. This related question has answers with more info.
If you want to use classes to store data (e.g. like using 'active', 'inactive' classes as switches), you're best off using Raphael's .data function which apparently is for storing arbitrary values. This related question has answers with more info.