Skip to content

Instantly share code, notes, and snippets.

@alexnaspo
Created September 23, 2014 17:48
Show Gist options
  • Save alexnaspo/9e3f2bdf4e6400c4be74 to your computer and use it in GitHub Desktop.
Save alexnaspo/9e3f2bdf4e6400c4be74 to your computer and use it in GitHub Desktop.
backgrid datetimepicker cell with bootstrap 3
# create a datetimepicker cell when using backgrid and the bootstrap3-datetimepicker
# this can be modified to work with other datepicker libraries
# http://eonasdan.github.io/bootstrap-datetimepicker/
# http://backgridjs.com/
MyDatePickerCellEditor = Backgrid.InputCellEditor.extend(
events: {}
initialize: ->
Backgrid.InputCellEditor::initialize.apply this, arguments
input = this
$(@el).datetimepicker({pickTime: false}).on 'dp.hide', (e) ->
e.preventDefault();
command = new Backgrid.Command({})
input.model.set input.column.get("name"), e.date.format('YYYY-MM-DD')
input.model.trigger "backgrid:edited", input.model, input.column, command
command = input = null
return
return
)
MyDatePickerCell = Backgrid.Cell.extend(editor: MyDatePickerCellEditor)
@juancarlosfarah
Copy link

Hi! Thanks for sharing this, it's super helpful. Quick question, I'm using something very similar for a datetimepicker cell/cell editor, but I keep getting the error below. Did you experience the same issue? If so, may I ask how you resolved it? Thanks!

Uncaught Error: datetimepicker component should be placed within a relative positioned container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment