     initialize: (args) ->
       super({})
       @args = args
+      @model = @args.column.editorModel
       @render()
       @$el.appendTo(@args.container)
 

      @defaultValue = if value? then value else @emptyValue
      @setValue(@defaultValue)

    validate: () ->
      if @args.column.validator
        result = @args.column.validator(@getValue())
        if !result.valid
          return result

      return { valid: true, msg: null }

  class StringEditorView extends CellEditorView

    emptyValue: ""

    el: '<input type="text" class="bk-cell-editor bk-cell-editor-string" />'

    render: () ->
      @$el.bind "keydown.nav", (event) =>
        if event.keyCode == $.ui.keyCode.LEFT or event.keyCode == $.ui.keyCode.RIGHT
          event.stopImmediatePropagation()
      @focus()
      @$el.select()

    loadValue: (item) ->
      super(item)

    model: IntEditor

  class NumberEditorView extends CellEditorView

    el: '<input type="text" class="bk-cell-editor bk-cell-editor-number" />'

    render: () ->
      @$el.spinner(step: @model.get("step"))
      @disable_horizontal_navigation()
      @disable_vertical_navigation()
      @$el.focus().select()

    remove: () ->
      @$el.spinner("destroy")
      super()

    serializeValue: () ->
      return parseFloat(@getValue()) || 0.0

    loadValue: (item) ->
      super(item)
      @$el[0].defaultValue = @defaultValue
      @$el.select()

    validateValue: (value) ->
      if isNaN(value)
        return { valid: false, msg: "Please enter a valid number"}
      else
        return super(value)

  class NumberEditor extends CellEditor
    type: 'NumberEditor'
