Friday, February 19, 2010

Grouping and Sorting grid GXT

If sorting has to be applied with grouping, grouping should be done first and then sort should be applied. This is because GXT grid grouping changes the sort order based on the grouping.

Monday, February 15, 2010

Array functions in javascript

Finally my first post of the year. Coding in core javascript scared me from the beginning because it does not have a perfect IDE with intellisense as java for eclipse. Coming to the point, I decided to improve myself in javascript. I was actually going through the arrays in javascript and read about some interesting functions. So decided to jot them down for my reference later. I am not sure how popular or how efficient these functions are. Most of my work's application is developed in javascript and I dont remember seeing any of these functions.

Lets consider we created an array      

  var array = ['kolli','ravi'];

Coming to the functions:

1) Push and pop: These are the simple functions that we all know since our undergrad mostly in data structures, stacks. So in an array push adds an element to the end of the array and pop deletes an element from the end of the array.

Eg:

array.push('kanth');

This statement adds ‘kanth’ to the end of the array now the array being [‘kolli’,’ravi’,’kanth’]

array.pop();

This statement removes the last element in the array resulting in [‘kolli’,‘ravi’]

2) unshift and shift: These functions are also used to insert and remove elements from the array but from the other end (beginning of the array).

Eg:

array.unshift("hye");

This statement adds ‘Hye’ to the beginning of the array resulting in [‘hye’,’kolli’,’ravi’]

array.shift();

This statement removes the first element in the array. Result: [‘kolli’,’ravi’']

3) Splice: This is a little more complex function than the others. It can be used to add, remove, replace elements in the array.

Syntax:

splice(StartingPos, NoofItemsToDelete, Items_to_add);

Eg:

array.splice(2,0,'kanth');

This statement is going to insert ‘kanth’ at location 2 of the array, without deleting anything.

array.splice(2,1);

This statement is going to remove 1 element starting from position 2.

array.splice(1,1,'rocks');

This statement is going to replace the element in position 1 resulting in array [‘kolli’,’rocks’].

Finally one more advantage of this function is that it lets us add more than one element to the array by just separating them with a ‘,’.

Friday, November 20, 2009

chrome OS

Finally i got to install chrome OS on my Mac using virtual Box. Well installing it is not my own intelligence though. I was using this techcrunch article. Well google has almost all the basic applications that are needed for daily use and most importantly run on a browser.
Coming to the actual OS, it opens up a browser and you are going to stay in here all your time. Its a little weird in the beginning as I am used to a whole bunch of windows in my task bar.
1) Firstly it authentication is done with ur google account.
2) It has the gmail and google calendar in 2 tabs that cannot be removed.
3) Oddly enough, I am able to open multiple windows of the browser but I cannot actually see the list of all the windows as a whole to toggle between. I am not sure if I am doing something wrong but that is a required must.

I can say that on a whole it looks like working only on chrome browser on my windows machine. Nothing essentially great about it. But the actual idea of having an OS exclusively to browse the web is pretty good.

I am also not sure about how far this is going to be useful in the netbook world too, because as far as i have read, it has its own hardware requirements, which might mean that once i get a netbook with chrome OS i might not be able to change my operating system to something else if I am actually not interested in it. Well as it has been now released into the open source world and it has almost one year to go before it is released, i am positive that it will be made to something pretty awesome by then.

Monday, November 9, 2009

Changing the grid CSS

Well, most of you guys might have known this, I am just putting it in for my reference.

Problem: If my application uses multiple grids and i want to have different CSS for each of the grids. What should i do?

Solution: 1) Set the Id of the grid.

grid.setId("myGrid");

2) Lets say I want to change the cell height and add borders to the cell of the above grid, I can change it by changing the css for that particular grid.

#myGrid .x-grid3-cell-inner 
{
    HEIGHT : 30px !important;  
    border: 1px solid #C0C0C0 !important;
}

Monday, October 19, 2009

How to set the grid row style?

Well the column style can be set using the GridCellRenderer, but there is a completely different way to set the style of a row.

GridViewConfig gvc = new GridViewConfig(){
public String getRowStyle(ModelData model, int rowIndex, ListStore ds) {
    return "row-Style";  // Style to be set to a row
  }
};
grid.getView().setViewConfig(gvc);

User specific conditions can be checked in getRowStyle to set different styles to different rows.