Forum


18:47

17/10/2008

I have a onInitializeForm function that is supposed to pop up the datepicker on focus in the edit form. However it never pops up. I also don't see any JavaScript errors so I'm not sure what is happening.
Grid code as follows. Some of the bits are replaced by ASP.NET when this page is rendered (using the ASP.NET MVC Framework). The grid itself works great, just the date picker won't show.
<table id="list1" class="scroll">
</table>
<div id="pager1" class="scroll" style="text-align: center;">
</div>
<script type="text/javascript">
var lastsel;
$(document).ready(function(){
$("#list1").jqGrid({
url:'<%=Html.BuildUrlFromExpression<AnnouncementController>(c => c.ListJSON())%>',
datatype: 'json',
mtype: 'GET',
altRows: true,
hidegrid: false,
toolbar: [true, 'top'],
colNames:['Actions','Id', 'Date', 'Title', 'Text'],
colModel :[
{name:'act',index:'act', width:75,sortable:false},
{name:'id',index:'id',width:55,resizable:true, hidden: true, editable:false,editoptions:{readonly:true,size:10}},
{name:'date',index:'date',width:120, resizable:true, sorttype:"date", editable:true,editoptions:{size:20}},
{name:'title',index:'title',width:400,resizable:true, editable:true,editoptions:{size:50}},
{name:'text',index:'text',width:120, hidden:true, resizable:true, editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}},
],
pager: jQuery('#pager1'),
rowNum:10,
rowList:[1, 5,10,20,30],
viewrecords: true,
multiselect: false,
sortname: 'Date',
sortorder: "desc",
imgpath: '<%=ResolveUrl("~//Content/jqgrid/themes/basic/images") %>',
caption: 'Announcements',
editurl: '<%=Html.BuildUrlFromExpression<AnnouncementController>(c => c.Edit())%>'
}).navGrid('#pager1', // Pager div
{add: false, edit:true, del:false, search: false}, // Options
{height: 280, width: 500, reloadAfterSubmit: false, // Edit Options
onInitializeForm : function(formid) {
jQuery("#date",formid).datepicker({showOn: 'focus'});
}
},
{}, // Add options
{} // Delete Options
);
});
Thoughts?
09:08

Moderators
30/10/2007

Hello,
I do not see nothing special here. Verify that datepicker plugin is loaded.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
13:33

17/10/2008

OK I messed around some more and got closer. Turns out I had the CSS file missing or something, so it is now displaying…sort of.
1) It renders BEHIND the form window.
2) when I click on a date, it closes the form window not quite what I want.It appears it is doing a close and not a save (ovbiouslly) since the value never changes.
I believe I'm using jqGrid 3.3 as I just downloaded this the other day.
Update: Further messing around seems to indicate my problems are with the datepicker appearing behind the edit form. Attempts to tweak z-order have failed (but I believe this was corrected?).
07:44

Moderators
30/10/2007

Hello,
Check the z-index of the form and the datepicker.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
13:03

17/10/2008

OK that sorted that problem out. Thank you. Turns out the datepicker-div was set to 20 or 30 z-index. Took some digging with FireBug to figure that out. Now it shows up properly.
However I've discovered another issue. I have two date fields, one right after the other. If I use the onfocus event, I get them to pop-up, but the second one always seems to populate the first. Actually what happens is I click in the second, the picker pops up, I select a date, it goes away and the first one immediately pops up WITHOUT changing the value of the second text box. If I use the button function, everything works.
Additionally, the onFocus fires when the form loads and I get a datepicker showing right away. This is actually not unexpected since one of the date elements is the first form field so this is probably functioning as usual.
I prefer the button option personally so I'll use that, but it was a little odd.
Thanks!
Jack
01:10

Moderators
30/10/2007

Hello,
It is not a jqGrid problem actually. This behavior come from jqModal wich try to focus the first input element if there is form in the modal.
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
59 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66