How to get datepicker in jqGrid search toolbar?
Asked Answered
T

5

8

I want to have datepicker in search text fields and eventually also in edit fields of a jqgrid.

Is there any way?

Has any one used such combination? Datepicker with jqGrid?

Tamarind answered 4/8, 2010 at 17:31 Comment(0)
T
5

I found the way:

It is hidden somewhere deep in the documentation:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:search_config

Tamarind answered 6/8, 2010 at 15:31 Comment(0)
C
10

You will do following in field definition,

colModel: [{ name: 'Start', index: 'Start', searchoptions: { sopt: ['eq', 'ne'], 
dataInit: function (elem) { $(elem).datepicker({ showButtonPanel: true }) } } },
Charmeuse answered 19/8, 2011 at 9:31 Comment(0)
T
5

I found the way:

It is hidden somewhere deep in the documentation:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:search_config

Tamarind answered 6/8, 2010 at 15:31 Comment(0)
H
2

Try :

{ name: 'AWBDate', index: 'AWBDate', width: 90, align: 'left', editable: false, formatter: 'date',search: true,

            formatoptions: {
                srcformat: 'd/m/Y H:i:s',
                newformat: 'd/m/Y'
            },
            sorttype:"date",
            searchoptions: {
                sopt: ['eq'],
                dataInit: function (elem) {
                    $(elem).datepicker({
                        dateFormat: 'dd/mm/yy',
                        changeYear: true,
                        changeMonth: true,                            
                        showWeek: true,
                        onSelect: function (dateText, inst) {
                            setTimeout(function () {
                                $('#jQGridapproval')[0].triggerToolbar();
                            }, 100);
                        }
                    });
                }
            }
        },
Harker answered 18/12, 2013 at 14:0 Comment(0)
D
2

This code worked for me.

colModel: [ 
    {
        name: 'created_at',
        index: 'Creation Date',
        search: true,
        searchoptions: {
            sopt: ['eq'],
            dataInit: function(e) {
                $(e).datepicker({
                        dateFormat: 'yy-mm-dd'
                    })
                    .change(function() {
                        $("#list2")[0].triggerToolbar();
                    });
            }
        }
    },
]

$("#list2") is the jqgrid table selector.

Dogcatcher answered 27/9, 2016 at 12:23 Comment(0)
B
0
colModel:[
    { name: "DateFrom", width: 110, index: 'DateFrom', search: true,
        searchoptions: {      dataInit: function(el) {
            $(el).datepicker({
                changeYear: true,
                changeMonth: true,
                showButtonPanel: true,
                dateFormat: 'dd-mm-yy'
            });
        }
        }
    }
]
Braggadocio answered 4/4, 2013 at 13:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.