首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >meteor中的可编辑表格

meteor中的可编辑表格
EN

Stack Overflow用户
提问于 2015-03-23 18:21:56
回答 2查看 3.4K关注 0票数 4

我希望在meteor中创建一个可编辑的表。

我已经浏览了以下链接:

reactive tableautoform

但是无法到达任何地方,我找对地方了吗?请指导。我是meteor的新手,任何帮助都将是appreciated.Thanks

EN

回答 2

Stack Overflow用户

发布于 2015-10-06 19:52:31

我只是使用纯js创建了一个可编辑的表格,并通过bootstrap、语义UI或任何你想要的东西来设计它的样式。以下是我的表行模板

代码语言:javascript
复制
<template name="item">
  {{#if editing}}
    <tr>
      <td><input type="text" id="editItemStore" value="{{store}}"></td>
      <td><input type="text" id="editItemName" value="{{name}}"></td>
      <td><input type="text" id="editItemWeight" value="{{weight}}"></td>
      <td><input type="text" id="editItemWeightType" value="{{weightType}}"></td>
      <td><input type="text" id="editItemQty" value="{{qty}}"></td>
      <td><input type="text" id="editItemQtyType" value="{{qtyType}}"></td>
      <td><input type="text" id="editItemPrice" value="{{price}}"></td>
      <td><button class="saveItem">save</button><button class="cancelItem">Cancel</button>{{#each errors}}<div>{{message}}</div>{{/each}}</td>
    </tr>
  {{else}}
    <tr>
      <td>{{store}}</td>
      <td>{{name}}</td>
      <td>{{weight}}</td>
      <td>{{weightType}}</td>
      <td>{{qty}}</td>
      <td>{{qtyType}}</td>
      <td>{{price}}</td>
      <td><button class="editItem">Edit</button><button class="deleteItem">Delete</button></td>
    </tr>
  {{/if}}
</template>

下面是我的行模板事件处理程序

代码语言:javascript
复制
Template.item.helpers({
  editing: function(){
    return Session.equals('editItemId', this._id);
  } 
});

Template.item.events({
  'click .deleteItem': function(){
    Items.remove(this._id);
  },
  'click .editItem': function(){
    Session.set('editItemId', this._id);
  },
  'click .cancelItem': function(){
    Session.set('editItemId', null);
  },
  'click .saveItem': function(){
    saveItem();
  },
  'keypress input': function(e){
    if(e.keyCode === 13){
      saveItem();
    }
    else if(e.keyCode === 27){
      Session.set('editItemId', null);
    }
  }
});
var saveItem = function(){
  var editItem = {
    store: $("#editItemStore").val(),
    name: $("#editItemName").val(),
    weight: $("#editItemWeight").val(),
    weightType: $("#editItemWeightType").val(),
    qty: $("#editItemQty").val(),
    qtyType: $("#editItemQtyType").val(),
    price: $("#editItemPrice").val()
  }

  Items.update(Session.get('editItemId'), {$set: editItem});
  Session.set('editItemId', null);
}

请参考此Complete Tutorial

票数 2
EN

Stack Overflow用户

发布于 2015-07-13 18:10:47

我使用meteor add olragon:handsontable

它工作得很好。查看tutorialsdocs

Excel是一个具有

外观的数据网格组件。它内置在JavaScript中,可以与任何数据源集成,效率最高。它具有强大的功能,如数据验证,排序,分组,数据绑定,公式支持或列排序。由Handsoncode团队和GitHub社区构建并积极支持,在麻省理工学院许可下免费分发。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29207795

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档