Welcome Guest Search | Active Topics | Sign In | Register

How can I implement a Select All checkbox for the CheckboxColumn Options
Jack.Wu
Posted: Saturday, January 16, 2010 9:26:28 PM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
I am your new customer and would like to know if there is any example code for implement a Select All Checkbox in the Grid Control's column header?
eo_support
Posted: Monday, January 18, 2010 10:13:02 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Thank you very much for your business. You will need to set the column's HeaderText to something like this:

Code: HTML/ASPX
<span onclick="check_all()"></span>


Here "check_all" is a JavaScript function you would need to provide to check all items:

Code: JavaScript
function check_all()
{
    //Get the Grid object. You will need to change "Grid1"
    //to the ID of your Grid object
    var grid = eo_GetObject("Grid1");

    //Now check all items
    for (var i = 0; i < grid.getItemCount(); i++)
    {
        var item = grid.getItem(i);

        //Get the first cell. If your checkbox column is not
        //the first column, you will need to change 0 to the
        //correct column index
        var cell = item.getCell(0);
        cell.setValue(1);
    }
}


Hope this helps.

Thanks
Jack.Wu
Posted: Monday, January 18, 2010 11:40:08 AM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
Hello Sir,

I have a question about the example javascript you gave. Where is the function of eo_GetObject("Grid1")? And what is your suggestion in the CheckBoxColumn HeaderText? Is it a button?

How can I do if I put a "<input type="checkbox" name="SelectAll" value="SelectAll" />" in the HeaderText? What I mean is to put a checkbox control in the HeaderText of CheckBoxColumn to provide the select all feature. Can you let me know how to do that? Thank you very much.
eo_support
Posted: Monday, January 18, 2010 12:14:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

eo_GetObject is one of the function provided by our client side API. We provide a set of global JavaScript functions and objects for you to program our controls on the client side. You can find more details here:

http://doc.essentialobjects.com/library/1/clientapi_howto.aspx

You can put any valid HTML inside a columns' HeaderText. However there is nothing "automatic" here. So for example, you can put a "SelectAll" checkbox there, but checking that checkbox will not automatically check all items unless you program it to do so ---- for example, handle that checkbox's click event and then call check_all like the previous sample.

Please feel free to let us know if you have any more questions.

Thanks!
Jack.Wu
Posted: Monday, January 18, 2010 2:09:26 PM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
After I tried your example, it can not update the CheckBox item in the Grid control. I added the code in the HeaderText of CheckBoxColumn like "<input type="checkbox" name="SelectAll" value="SelectAll" onclick="check_all()"><br>" and add a javascript as your samle above. But when I check the box of the Header text, it is not working. Would you mind let me know if there is something missing? Thank you.
eo_support
Posted: Monday, January 18, 2010 2:55:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I can't tell you exactly why it's not working without see the full page. Can you try to create a test page that demonstrates the problem? As soon as we can run it here and see what you are seeing, it should be quite easy for us to tell you what's wrong.

Thanks!
Jack.Wu
Posted: Tuesday, January 19, 2010 10:26:14 AM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
I found the problem. And there is another problem that when using the grid and progress bar, I always can not get the checkeditem with the ProgressBar_RunTask event. I had build a test page, how can I send it to you so you can help to let me know how to use the ProgressBar correctly. Thank you.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.