PDA

View Full Version : Finding the max length with in a store



webfriend13
12 Jun 2012, 10:26 PM
HI all,

I have a store which have 7 columns and contains about 50 rows. For every column, I want to loop through the rows and want to return the maxium length based on the content of the cell in each row .


Col1

Col2

Col 3



a

aa

aaa



b

bb

bbb



c

cc

ccc



d

hello

ddd



e

ee

eeee



f

ff

ffff



1

5

4






The output should come as 1 5 4

el_chief
13 Jun 2012, 11:36 AM
1. Can't this happen on the server?

2. I am not going to provide a full solution for you, as it should be pretty simple to figure out, but a basic implementation would iterate each row, find the length in property1, remember it, and return the largest one. You'd have to loop again, looking at the second property (column).

These functions should help:

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-each

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/length (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-each)