Hello!
I have to edit object's slot in form by the gridedit.
I defined presentation that use gridedit widget.
Here is the code of presentation:

(defclass gridedit-presentation (presentation)
  ((view :initarg :view :reader view-of
         :doumentation "Gridedit view")
   (form-view :initarg :form-view :reader form-view-of
              :documentation "View of element form")
   (data-class :initarg :data-class :reader data-class-of
               :documentation "The class for creating new objects")
   (store :accessor store-of
          :documentation "Store ")))

(defmethod render-view-field-value (value (presentation gridedit-
presentation) (field form-view-field) (view form-view) widget obj
&rest args)
  (declare (ignore args))
  (let ((view (view-of presentation))
        (store (weblocks-memory:make-scratch-store (map 'list (lambda (a) a)
value))))
    (render-widget-body
     (make-instance 'gridedit :view view
                                  :item-data-view view
                                  :item-form-view (form-view-of presentation)
                                  :data-class (data-class-of presentation)
                                  :class-store store))
    (setf (store-of presentation) store)))

Use example:

(defvar *next-id* -1)

(defclass weblocks-object ()
  ((weblocks:id :initform (incf *next-id*) :reader id-of)))

(defclass counteragent (weblocks-object)
  ((name :initarg name :accessor name-of)
   (employees :initform nil :accessor employees-of)))

(defmethod print-view-field-value ((value counteragent) presentation
field view widget obj &rest args)
  (declare (ignore presentation obj view field args))
  (name-of value))

(defview counteragent-grid-view (:type table :inherit-from '(:scaffold
counteragent))
  (id :hidep t)
  (name :label "Name")
  (employees :hidep t))

(defview counteragent-form-view (:type form :inherit-from '(:scaffold
counteragent) :caption "Counteragent")
  (id :hidep t)
  (name :label "Name")
  (employees :label "Employees"
                     :present-as (gridedit  :view 'employee-grid-view
                                                                :form-
view 'employee-form-view
                                                                :data-
class 'employee)))

(defclass employee (weblocks-object)
  ((first-name :initarg :name :accessor name-of)
   (second-name :initarg :second-name :accessor second-name-of)
   (third-name :initarg :third-name :accessor third-name-of)))

(defun print-employee (employee)
  (with-slots (first-name second-name third-name) employee
    (format nil "~a ~a. ~a." second-name (char first-name 0) (char
third-name 0))))

(defmethod print-view-field-value ((value employee) presentation field
view widget obj &rest args)
  (declare (ignore presentation obj view field args))
  (print-employee value))

(defview employee-grid-view (:type table :inherit-from '(:scaffold
employee))
  (second-name :label "Second name")
  (first-name :label "First name")
  (third-name :label "Third name"))

(defview employee-form-view (:type form :inherit-from '(:scaffold
employee) :caption "Employee")
  (second-name :label "Second name")
  (first-name :label "First name")
  (third-name :label "Third name"))

Then I try to edit or add new item. After selecting item in grid to
edit or press "add" button the form of item doesn't appear, and I
can't edit item slots.
I put gridedit store to presentation slot that, as I see, is wrong.
Where is the right place to put gridedit store or how I can access
gridedit to store in "parse-view-field-value" method?

-- 
You received this message because you are subscribed to the Google Groups 
"weblocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/weblocks?hl=en.

Reply via email to