Calendar challenges

Hi,



I’m trying to use the calendar control and I want to bind it multiple inputs. Two of the input field are on dhtml tab pages (Divs not iframes) and one is elsewhere on the same page. I want to share the between these controls, meaning I need to reset it properly before it is launched.



This was just background for my ACTUAL question. I see some help topics on accomplishing the aforementioned task, which I will read.



My ACTUAL question is about firing close() for the calendar whenever another control receives focus (or put another way, when the calendar is blurred).



Currently the calendar just hangs around if I click into another control. I started to make a dhtmlxevent call for the blur event before realizing I don’t have an element to which I can bind the event.



So:



How do I get the calendar control to close when I’ve clicked on another control? Keep in mind that the other control I click on might be another calendar-bound input.



Thanks in advance!



On a side note: I notice the calendar take a moment to load the first time the input is clicked. After that it is pretty snappy. Is there any way to preload the calendar beyond drawing it somewhere hidden to avoid the user experiencing that upfront cost?



my address is ( bz ajc rbutler ) reversed with an at-sign and a dot.




You can use body onclick to close calendar.


dhtmlxEvent(document.body, “click”, function(){


dhxCal.hide();

});



Hi, finally got back to this calendar control and so I tried this solution. It did not work for me.
I placed this line in my page’s oninit function:

    dhtmlxEvent(document.body, “click”, dhtmlxCloser);

dhtmlxCloser is another function. I set a breakpoint at the beginning of the function. The breakpoint is never reached and thus the calendar is not closed.

function dhtmlxCloser()
{
    if (myCal.IsVisible()) myCal.hide();
}

On a related note, assuming we can get this to work, I have two grids on the same page for which I would like to leverage this same function in order to call editStop() on the appropriate grid. I cannot find a reliable way of determining whether or not a grid is active. (I will search the KB but thought I’d sneak the question in here).


Thanks, Rich


Hello,


>>The breakpoint is never reached and thus the calendar is not closed.


If you click on the element which already has onclick event handler with canceled bubbling, the body onclick won’t be called.


In this case you should call dhtmlxCloser() from each onclick event handler you already set.


For grid - you can use onRowSelect event handler: grid.attachEvent(“onRowSelect”,function(){dhtmlxCloser()})


>> I have two grids on the same page for which I would like to leverage this same function in order to call editStop() on the appropriate grid. I cannot find a reliable way of determining whether or not a grid is active.


editStop() can be called for both grids - the editor will be closed.

hm,  I was able to go back add an onclick handler to the body tag and that actually fires. I thought I’d tried adding an onclick to the body months back with no success. But since it works, I’ll use that instead as the dhtmlxevent still didn’t fire.

On the second part, I apologize but I probably wasn’t clear in what I need. I don’t need an event handler, what I want is to know how I can programmatically determine if the dhtmlx grid is in edit mode.  Could I possibly query the grid for the current cell and if it returns a non-negative value then I would call editstop()?


You can try to use the following check:


if (grid.editor) grid.editStop();



That works great, thanks!