|
Rank: Member Groups: Member
Joined: 11/25/2008 Posts: 22
|
I have a checkbox column I would like a button in the header to select all of the corresponding checkboxes in that column. It seems like i needs to be done with javascript but i can't find an example of how to set the checkboxes to true in a column. Is there somewhere in the documentation i can see a sample?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You would do something like this:
Code: JavaScript
function check_all()
{
//Get the grid object. This code assumes the Grid's ClientID is
//"Grid1", you will need to change this the real ClientID of your
//Grid
var grid = eo_GetObject("Grid1");
//Loop through all grid items
for (var i = 0; i < grid.getItemCount(); i++)
{
//Get the grid item
var gridItem = grid.getItem(i);
//Get the grid cell
var gridCell = gridItem.getCell(1);
//Check/uncheck the cell. Use "1" to check the cell,
//use "0" to uncheck
cell.setValue("1");
}
}
To call it from Grid header, set the GridColumn's HeaderText to something like this:
Code: HTML/ASPX
<div onclick="check_all()">Check All</div>
Hope this helps. Thanks
|
|
Rank: Member Groups: Member
Joined: 11/25/2008 Posts: 22
|
Thanks for the response.
This Line generated an error so i changed "cell" to gridCell
//Check/uncheck the cell. Use "1" to check the cell, //use "0" to uncheck cell.setValue("1"); but it doesn't check anything off. I really only want to check off a column so wouldn't i need to specific the column that was clicked on somehow and set that index too?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Sorry about the typo. It should be "gridCell" instead of cell.
The index is specified by "gridItem.getCell(1)". Here "1" is the column index. You will need to change that to your column index.
Thanks
|
|
Rank: Member Groups: Member
Joined: 11/25/2008 Posts: 22
|
Thanks so much for your help. Sorry for all the questions, i've never really used javascript before or the gridview object from eo (usually stick to the menu and toolbar objects).
Is there a way to get the column index of the column header selected? it totally works when i hard code the column number but i need it to be dynamic? i did try finding it in the documentation but i must be searching for the wrong thing.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I don’t believe you need that. The whole solution is your code from beginning to the end. You are not really clicking the GridColumn header. You are clicking a piece of HTML code that you put in your page. You can change that code to do whatever you need, including passing any necessary parameter if you need to. There would be no difference if the code is triggered by a button instead of a piece of HTML you put in the Grid header.
You may want to ask someone who has more experience with JavaScript to help you if you are still confused. We are happy to point you to the right direction and explain anything that is special about our product to you, but we are not in a position to code for you or to explain general Web programming technique/knowledge to you.
Thanks
|
|