1

ファイルアップロード用のキャリアウェーブを備えた単一のフィールドを持つモデルがあります。Google グループを検索しましたが、ファイルのアップロードを netzke コンポーネントに追加する簡単な方法が見つかりません。通常のブラウザ ファイル アップロードを使用してパネル ビューで実行できれば満足です。特別なことは必要ありません。

デモの 1 つに、ファイルのアップロード、カスタム レイアウトのページング フォームがあるのを見たところです。それをBasepack Gridに入れる方法については、まだガイダンスが必要だと思います

4

1 に答える 1

2

ファイルアップロードフィールドを最初に追加する必要がありますBasepack::Form(その後、個別にテストできます):

class AttachmentForm < Netzke::Basepack::Form
  def configure(c)
    super
    c.model = "Attachment"
    c.items = [{xtype: :fileuploadfield, name: 'attachment'}]
  end
end

次に、組み込みのフォームではなく、このフォームを使用するようにグリッドを構成する必要があります。

class AttachmentGrid < Netzke::Basepack::Grid
  def configure(c)
    super
    c.model = 'Attachment'
    c.force_fit = true
    c.columns = [:link]
    c.bbar = [:add_in_form, :del]
  end

  def preconfigure_record_window(c)
    super
    c.form_config.klass = AttachmentForm
    c.width = 600
    c.height = 150
  end
end

参考までに、Attachmentモデルは次のとおりです。

class Attachment < ActiveRecord::Base
  mount_uploader :attachment

  # this is a virtual column referred to from `AttachmentGrid`;
  # can be moved over to grid itself using `getter` in case
  # you object putting HTML into the model
  def link
    "<a href='#{attachment.url}' target='_blank'>#{attachment.file.try(:identifier)}</a>"
  end
end
于 2013-01-13T00:37:49.373 に答える