如何为backgrid单元格添加日期选择器

时间:2013-09-13 08:09:45

标签: datepicker backgrid

我正在使用backgrid来实现网格功能,我需要将一个datepicker添加到backgrid单元格而不是使用Backgrid.DateCell。等待你的回复

samplecode:

           datagrid(collection) : {

                      colomns = [{

                                name : "name",
                    label: "Name",
                    cell : string
                                },
                                {

                                name : "date",
                    label: "Date",
                    cell : string
                                }
                              }],
                        var lgrid = new Backgrid.Grid({
                    columns: columns,
                    collection: collection,
                    emptyText: "no data"
             });
                   this.$("#grids").append(lgrid.render().$el);

                     }

这些是在backgrid中定义的列。我需要使用datepicker在字符串单元格中填充日期当我点击日期的字符串单元格时,应该打开一个日期选择器,我需要在单元格中选择日期。请帮帮我....

谢谢&问候   gangadhar v

2 个答案:

答案 0 :(得分:1)

可能有更好的方法来实现它,但我能够这样做。

MyDatePickerCell = Backgrid.Cell.extend({
    editor: MyDatePickerCellEditor,
});

MyDatePickerCellEditor = Backgrid.InputCellEditor.extend({
    events:{},
    initialize:function(){
        Backgrid.InputCellEditor.prototype.initialize.apply(this, arguments);
        var input = this;
        $(this.el).datepicker({
            onClose: function(newValue){
                var command = new Backgrid.Command({});
                input.model.set(input.column.get("name"), newValue);
                input.model.trigger("backgrid:edited", input.model, input.column, command);
                command = input = null;
            }
        });
    },
});

答案 1 :(得分:0)

onClose不会在我第一次选择日期时触发。在第二次尝试后,它可以完美运行。 我不知道如何解决这个问题。

相关问题