1

I am implementing Dojo EnhancedGrid with pagination and there is something called items per page.

10 | 20 | 30 | 40  | 50| all.

Suppose I select here 20 in the EnhancedGrid pagination. How to access the value 20 from the program? I want to get this value and store it in a variable say Page-size. I am using Dojo version 1.6.1

Ovidiu Dolha
  • 5,335
  • 1
  • 21
  • 30
Ashish
  • 45
  • 1
  • 7

2 Answers2

1

You can access the page size in dojo 1.6 using this:

yourGrid.pagination.plugin.pageSize;

Here is a working jsfiddle using dojo 1.6:

http://jsfiddle.net/SM8GS/1/

It uses the onClick event of the grid. Each time you click on the grid it alerts the current page size.

Please edit your initial question & add the dojo version to it !

Lucian

Lucian Depold
  • 1,999
  • 2
  • 14
  • 25
  • Thanks for the reply. Tried it. It says: `gridZoneMember.plugins.pagination.currentPageSize` is not a function. – Ashish Mar 08 '13 at 06:34
  • what dojo version are you using ? could you provide a jsfiddle with you example & the error ? – Lucian Depold Mar 08 '13 at 06:57
  • oh.Thank you very much for pointing out that. I am using a DOJO version 1.6. And the JSFriddle which i was trying to execute is: http://jsfiddle.net/KDTcC/3/ which executes in 1.7 and 1.8 dojo.Where as not in 1.6. So that gave me a solution.i have one question for you. Now suppose if i replace my Dojo 1.6 library with 1.7 will my code work..?? – Ashish Mar 08 '13 at 07:24
  • can't say that for sure. but dojo should be backward compatible. you have to try it. i would not use 1.6 anymore, 1.8 has a lot of new features & makes more sense. did that solve your problem already ? – Lucian Depold Mar 08 '13 at 07:33
  • i ve edited my post & added a jsfiddle with a working example based on dimitri's post – Lucian Depold Mar 08 '13 at 07:39
  • Thanks but my problem is not solved as i have to use dojo 1.6 and this thing doesn't work there. :( is there a way to do this in 1.6? – Ashish Mar 08 '13 at 07:54
  • please add the dojo version to your question – Lucian Depold Mar 08 '13 at 09:24
  • i've already added :) where did u find this "pageSize" i did not find this in documentation... – Ashish Mar 08 '13 at 09:25
  • If you want to know something about objects in javascript use console.log(YOUROBJECT). After logging the object you can browse it using firebug. You can take a look into the available methods & properties, and there was a pagination object in the grid object, within the pagination object there was a plugin object and the plugin object had a pageSize attribute... – Lucian Depold Mar 08 '13 at 09:29
  • hats off man!! I'm new to DOJO and JS , will keep this in mind from next time and thanks again... – Ashish Mar 08 '13 at 09:33
1

The documentation states that there is a currentPageSize() method. You can access it directly from the EnhancedGrid object. I made a JSFiddle to test this. At the bottom of the script you can find the following code:

// Display current page size
grid.on("RowClick", function() {
   alert(grid.currentPageSize());    
});

Change the pagesize and click any row to see the result.

The rest of the code is copy-pasted from the documentation just to get a simple example of the enhanced grid (no special tricks are involved).

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
  • Thanks for the the reply. You were straight to the point. But that function seems to work on the JSFriddle.But on my PC its not working. I am getting a similar grid , but when i click it nothing happens. i.e. grid.on doesn't work. And also when i try execute `alert(grid.currentPageSize());` it says currentPageSize function not found. – Ashish Mar 08 '13 at 06:29
  • @Ashish it might be depending on the version of Dojo you're using. A lot of syntax changes happened since 1.6, so probably that is the issue. My example is using the latest Dojo toolkit version (1.8.3), which isn't the version you're using (but that information wasn't provided when I posted my answer). – g00glen00b Mar 08 '13 at 09:52
  • Yes thats true.. my website UI is coded in Dojo 1.6 so i have to stick to that now. :( Thanks for the reply :) helped a lot to solve the issue. – Ashish Mar 08 '13 at 10:09