This Question is Assumed Answered

1 "correct" answer available (5 pts) 15 "helpful" answers available (3 pts)
7 Replies Last post: May 29, 2008 6:16 AM by mgordon

Related to checkbutton column in RecordGrid.

May 23, 2008 6:51 AM

Click to view mannusanghi's profile Level 2 mannusanghi 26 posts since
Feb 27, 2008

Hi All...

My problem is related to Record Grid & CheckButton

I have a Record Grid in this i have CheckButton column.When i check a CheckButton , it selects a Record.

Currently a Record is selected,bt when i click elsewhere in RecordGrid. This CheckButton will get unchecked also record gets deselected .

Bt i want to keep the record selected untill check button is checked.

And once CheckButton is unchecked record will be deselected.


Regards,

Mannusanghi

Click to view carl's profile Curl carl 53 posts since
Oct 17, 2007
1. Re: Related to checkbutton column in RecordGrid. May 23, 2008 1:56 PM
Do you really want each record with a checked CheckButton to be part of the RecordGridSelection? Selection is affected by a number of other processes, and you would need to make changes to the UI's event handling code to ensure that the user could not affect the Selection other than by your intended means.

If alternatively you only need to mark records and not via a Selection, then that's much easier; e.g. see row-background-spec. Depending on your other desired functionality, you might then be able to turn off selection entirely -- though Selection can also coexist with this technique -- and use only your boolean state + row styling for whatever bulk operations you might provide.
Click to view mannusanghi's profile Level 2 mannusanghi 26 posts since
Feb 27, 2008
2. Re: Related to checkbutton column in RecordGrid. May 25, 2008 9:27 PM
in response to: carl

Thanks Carl for your suggestion..

Actually I want a RecordGrid with following requirements ...

1. There
should be a left-most column with CheckButtons on begining of each record
including its column header
2. when I check/uncheck at header CheckButton,
checkbuttons of all records should be checked/unchecked and all records should
be selected with appropriate selection color (now by default it is blue)
3.
When I click on blank spaces with in record grid, there will be no change to
already selected/ckecked records

You can think of standard mail interface
of google/yahoo.


Regards,

Mannusanghi

Click to view mgordon's profile Curl mgordon 36 posts since
Oct 17, 2007
3. Re: Related to checkbutton column in RecordGrid. May 28, 2008 8:54 AM
I think the best way to do this is to not use the built in record selection mechanism at all. Instead, use a boolean field in each record to indicate if the record is selected. Use a custom column header to get the select-all checkbutton at the top, and use a row-background-spec procedure to colorize the selected records. Here is some sample code:
{curl 6.0, 7.0 applet}
{title Checkbox in Header}

{import * from CURL.DATA-ACCESS.BASE}

{let dataset:RecordSet = 
    {RecordSet
        {RecordFields
            {RecordField "id", 
                caption = "ID", domain = int,
                index-type = RecordFieldIndexType.unique
            },
            {RecordField "Title", domain = String},
            {RecordField "Date", domain = {StandardDateDomain}},
            {RecordField "selected", caption = "\u221a", domain = bool}
        },
        {RecordData id = 1, Title = "Meeting Friday", Date = "2007-12-15"},
        {RecordData id = 2, Title = "Re: Meeting Friday", Date = "2007-12-16"},
        {RecordData id = 3, Title = "Re: Meeting Friday", Date = "2007-12-16"},
        {RecordData id = 4, 
            Title = "Need your help (financial transaction)",
            Date = "2008-04-01"
        },
        {RecordData id = 5, Title = "Good news", Date = "2008-05-05"}
    }
}

{let select-all-ctrl:CheckButton = 
    {CheckButton
        label = "",
        {on ValueChanged at cb:CheckButton do
            {with rg.records.batch-events? = true do
                {for r:Record key ri:int in rg.records do
                    set r["selected"] = cb.value
                }
            }
        }
    }
}

{let rg:RecordGrid = 
        {RecordGrid 
            width = 5in, height = 3in,
            background = "#f0f0f0",
            display-filler-column? = true,
            display-record-selectors? = false,
            display-navigation-panel? = false,
            record-source = dataset,
            editable? = true,
            select-current-record? = false,
            row-background-spec = 
                {proc {rg:RecordGrid, r:Record, ri:int}:#Background
                    {return 
                        {if r["selected"] asa bool then
                            "#ffff0080" 
                         else
                            null
                        }
                    }
                },
            automatic-columns? = false,
            {RecordGridColumn  width = 18pt, "selected", 
                header-spec = select-all-ctrl,
                halign = "center"
            },
            {RecordGridColumn  width = 3.5in, "Title"},
            {RecordGridColumn  width = 60pt, "Date"}
        }
}

{do
    {rg.records.add-event-handler
        {on RecordModified at rv:RecordView do
            let all?:bool = true
            {for r:Record key ri:int in rg.records do
                {if not rg.records[ri]["selected"] asa bool then
                    set all? = false
                    {break}
                }
            }
            set select-all-ctrl.value = all?
        }
    }
}

{value rg}
Click to view mannusanghi's profile Level 2 mannusanghi 26 posts since
Feb 27, 2008
4. Re: Related to checkbutton column in RecordGrid. May 28, 2008 11:26 PM
in response to: mgordon

Hi Mgordon

Thank you for your reply but it solves (selection mechanism) one aspect of my original problem .
Still I do not any idea how to add a really check button in the beginning of each record at left.

And if I check any record that record should be selected.

Plz see the image at http://help.allegheny.edu/tutorials/webct/images/exportparts/qdb_select.gif

I want to add same selection mechanism with the check button within a RecordGrid.

Thank you in adv

Click to view mgordon's profile Curl mgordon 36 posts since
Oct 17, 2007
5. Re: Related to checkbutton column in RecordGrid. May 29, 2008 4:55 AM
in response to: mannusanghi
The code I posted does give you a check button at the left of each record at the left. It looks a lot like the image you referenced. Please explain in greater detail the additional functionality you'd like to see.
Click to view mannusanghi's profile Level 2 mannusanghi 26 posts since
Feb 27, 2008
6. Re: Related to checkbutton column in RecordGrid. May 29, 2008 5:44 AM
in response to: mgordon

Hi mgordon...

I am getting checkbox at leftmost column but what i need is

1. On check of Header Checkbox all Rows gets selected and
all checkboxes in each row gets checked.

2. Similarly unChecking of Header Checkbox all rows gets deselected and
all checkboxes in each row gets unChecked.

3. When checks checkbox of a particular row it gets selected and vice versa on UnChecking CheckBox.

4. On Multiple checking of Row-checkboxes muliple rows gets selected. and vice versa on UnChecking CheckBoxes.

5. Problem is when i display any image in a RecordGridCell , on selection of a row this RecordGridCell doesnt take part in selection.

Every RecordGridCell should display selection background when row is selected.


6. Now the particular CheckBox is checked and that row is selected ,if i clicked any where in recordgrid it should remains selected and CheckBox checked.

but my problem is when i click anywhere in RecordGrid this particular row gets unchecked and deselected.


Regards,

Mannusanghi

Click to view mgordon's profile Curl mgordon 36 posts since
Oct 17, 2007
7. Re: Related to checkbutton column in RecordGrid. May 29, 2008 6:16 AM
in response to: mannusanghi
In my example code, I'm not using the built-in selection mechanism. I'm using the data model (the recordset) to represent the "selected" records. I believe it works the way you want it to for items (1) through (4). I'm not sure what you mean by item (5). It may be that the image doesn't look selected, even though it is part of a selected row. In my scheme, the yellow highlighting is applied to the row background, so it won't be seen if the image is opaque. You could add some margin to the image so that the background is at least visible in the margin.

It sounds like you are still using the selection mechanism in your code. That would explain (6).