[Dojo-interest] DataGrid: preventing change of selection?

Deno Vichas dvichas at autoreturn.com
Fri Apr 17 13:19:13 EDT 2009


I use the following to watch for form changes.

        dojo.query("input", "dispatchForm")
                .filter(
                    function(row) {
                        return dijit.byId(row.id) != null
                    })
                .forEach(
                    function(item) {
                        dojo.connect(dojo.byId(item.id), "onchange",
function(e) {
                            hasDispatchFormChanged = true;
                        });
                        dijit.connect(dojo.byId(item.id), "onChange",
function(e) {
                            hasDispatchFormChanged = true;
                        });
                    });


On the function connect to onRowClick on my grid I check the Boolean
value of hasDispatchFormChanged.  I'm using both dojo.connect and
dijit.connect has not all of my form elements are dijits.




-----Original Message-----
From: dojo-interest-bounces at mail.dojotoolkit.org
[mailto:dojo-interest-bounces at mail.dojotoolkit.org] On Behalf Of Devine,
James
Sent: Friday, April 17, 2009 7:58 AM
To: dojo-interest at mail.dojotoolkit.org
Subject: Re: [Dojo-interest] DataGrid: preventing change of selection?

If you are connecting to onSelected to populate the form, isn't this
where you would check to see whether you need to populate the form or
show the dialog?  Something this this:

- connect onSelected to saveAndShowData()

- function saveAndShowData() {
	if (formRequiresSave()) {
		var saved = showDialog()
		if (saved) { // as opposed to cancel
		  populateForm()
		}
	} else { 
		populateForm()
	}
}


-----Original Message-----
From: dojo-interest-bounces at mail.dojotoolkit.org
[mailto:dojo-interest-bounces at mail.dojotoolkit.org] On Behalf Of Michael
Schuerig
Sent: Friday, April 17, 2009 5:51 AM
To: dojo-interest at dojotoolkit.org
Subject: [Dojo-interest] DataGrid: preventing change of selection?


In a master-detail view consisting of a DataGrid and a form, the user 
selects an object from the grid (only showing some of the attributes) 
for editing in a form.

So far, I'm handling this by connecting to the grid's onSelected event 
(should it be onRowClick?). This works up to a point. When the form is 
changed, these changes are lost and overwritten by the attributes of the

newly selected object. In such a case, I'd like to intercept the change 
of selected object with a dialog asking whether to Cancel or to 
Discard/Save the changes first.

I've tried onCanSelect and onCanDeselect handlers to achieve this, but 
apparently they don't do what I want them to. Even statically returning 
false from both of them doesn't achieve what I want. And, yes, I've 
verified that they are actually called.

Michael

-- 
Michael Schuerig
mailto:michael at schuerig.de
http://www.schuerig.de/michael/

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest at mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest at mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


More information about the Dojo-interest mailing list