views:

4120

answers:

4

I have been able to work the Date Picker into JQGrid when editing inline, but I am unable to use it inside the add/edit window. Does anyone have instructions on how to do this or an example I can look at?

demo from that site of what I am trying to do: http://www.the-di-lab.com/demo/apples

I read that I could use the following method but not sure how to integrate it:

dataInit : function (elem) { $(elem).datepicker(); }

+1  A: 

It looks like they are using 'afterShowForm' to attach a date/color picker to a div.
(view source)

jQuery("#list").navGrid("#pager",{edit:true,add:true,del:true},
               {width:400,height:400,closeAfterEdit:true,
         afterShowForm:function(){   $("#jsrs").load("/demo/apples/jsrs"); },
         onclickSubmit:function() {  $("#jsrs").empty(); }
},

(view source)

http://www.the-di-lab.com/demo/apples/jsrs

//Js for colorPicker
$('#color').ColorPicker({
    onSubmit: function(hsb, hex, rgb) {
     $('#color').val("#"+hex);
    },
    onBeforeShow: function () {
     $(this).ColorPickerSetColor(this.value);
    }
}).bind('keyup', function(){
    $(this).ColorPickerSetColor(this.value);
});


//Js for datePicker
$('#date').DatePicker({
    format:'Y-m-d',
    date: $('#date').val(),
    current: $('#date').val(),
    starts: 1,
    position: 'bottom',
    onBeforeShow: function(){
     $('#date').DatePickerSetDate($('#date').val(), true);
    },
    onChange: function(formated, dates){
     $('#date').val(formated);
    }
    });

Thanks for finding this example, I was looking for how to do this as well.

dwright
Thank you, it is slowly coming together, the jsrs code is being triggered when the window opens but I am just getting the "$("#appointment").DatePicker is not a function" (I changed the instances of #date to #appointment since that is the id of the desired field)All the needed scripts/ui are there to get it working outside of the popup, Is there something I need to do that I might be missing? Thank You!!
kilrizzy
Oh I just needed "datepicker" instead of "DatePicker" THANKS!
kilrizzy
A: 

Adding datepicker is an easy task:

colModel: [
  ... other column definitions ...
  {
    name:'my_date', index:'my_date', label: 'Date', width: 80,
    editable: true, edittype: 'text',
    editoptions: {
      size: 10, maxlengh: 10,
      dataInit: function(element) {
        $(element).datepicker({dateFormat: 'yy.mm.dd'})
      }
    }
  },
  ... other column definitions ...
]

Of couse, instead of .datepicker you can use any plugin like colorpicker or autocomplete.

Best regards

-1, You have several errors in there... and that code doesn't seem to even work after fixing the errors
Fragsworth
A: 

Hi... I tried this but its not working for me.. can you please write done the complete functionality that displays how to integrate it with jsrc element....

A: 

Use this code to add datepicker to create/edit dialog:

.navGrid('#yourID',
                { edit: true, add: true, del: true, search: true }, //options
                {
                    ...  
                    onInitializeForm: function() {
                       $('#yourDate').datepicker(); 
                     },
                    onClose: function() {
                       //if you close dialog when the datepicker is shown
                       $('.hasDatepicker').datepicker("hide")
                    }
                },
                ...
katrin