更新现有HandsOnTable实例的设置

时间:2015-10-14 14:13:25

标签: javascript handsontable

我尝试动态更新HandsonTable设置。设置似乎更新​​,但渲染表仍使用以前的设置。

实施例: http://jsfiddle.net/kAFWA/30/

updateSettings文档:http://docs.handsontable.com/0.18.0/Core.html#updateSettings

Dir.chdir '/home/moot/pickaxe/pics'

pic_names = Dir['/media/moot/**/*.{CR2,cr2,JPG,jpg}']
puts nil
puts "What would you like to call this batch? e.g Subject_Location"
puts nil
batch_name = gets.chomp

require 'fileutils'
FileUtils::mkdir_p "#{batch_name}" 
Dir.chdir '/home/moot/pickaxe/pics/#{batch_name}'

puts nil
print "Downloading #{pic_names.length} Files: "

pic_number = 1

pic_names.each do |name|
  print 'ˁ˚ᴥ˚ˀ  ' 

  new_name = if pic_number < 10
    "#{batch_name} 0#{pic_number}_#{Time.now} .CR2"
  else
    "#{batch_name} #{pic_number}_#{Time.now} .CR2"
  end

  require 'fileutils'
  include FileUtils
  cp(name, new_name)  

  pic_number = pic_number + 1
end
puts nil
puts "Move Complete."
var ht;
$(document).ready(function() {

  $("#example1").handsontable({
    minRows: 5,
    minCols: 5,
    colHeaders: ["Header 1", "Header 2", "Header 3"],
    rowHeaders: true,
    contextMenu: {
      items: {
        "edit_Header": {
          name: "Edit this Header!!"
        }
      }
    }
  });

  ht = $('#example1').handsontable("getInstance");
});

function updateContextMenu() {

  console.log(ht);
  ht.updateSettings({
    minRows: 4,
    minCols: 4,
    colHeaders: ["Header 4", "Header 5", "Header 6"],
    contextMenu: {
      items: {
        "edit_Header": {
          name: "Another Text"
        },
      }
    }
  }, true);
  console.log('here');
  ht.render();
}

1 个答案:

答案 0 :(得分:0)

是的,所以你想摆脱你updateSettings的第二个论点。不知道它做了什么,但如果你在你的小提琴中摆脱它,它会正确更新。只是fyi,不需要重新渲染,因为无论如何它最终都会重新渲染。