How to get datepicker in jqGrid search toolbar?

2019-03-28 03:20发布

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?

5条回答
劳资没心,怎么记你
2楼-- · 2019-03-28 03:42

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);
                        }
                    });
                }
            }
        },
查看更多
闹够了就滚
3楼-- · 2019-03-28 03:43

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.

查看更多
看我几分像从前
4楼-- · 2019-03-28 03:44

I found the way:

It is hidden somewhere deep in the documentation:

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

查看更多
Bombasti
5楼-- · 2019-03-28 03:47

You will do following in field definition,

colModel: [{ name: 'Start', index: 'Start', searchoptions: { sopt: ['eq', 'ne'], 
dataInit: function (elem) { $(elem).datepicker({ showButtonPanel: true }) } } },
查看更多
老娘就宠你
6楼-- · 2019-03-28 03:48
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'
            });
        }
        }
    }
]
查看更多
登录 后发表回答