문제

From what I've been told, I need to create an IValueConverter to do my custom formatting. The problem is my formatting is one-way, there is no legitmate ConvertBack implementation.

So, how do I handle one-way IValueConverters. (If it helps, this is for a read-only control.)

도움이 되었습니까?

해결책

C 럼 ID_CAT에 의해 실현 된 원형 참조가있는 카테고리 테이블이 올바르게 이해할 수 있습니다.

다음 모델은 예상대로 작동해야합니다.

class Category < ActiveRecord::Base
  belongs_to :supercategory, :class_name => "Category", :foreign_key => "cat_id"
  has_many :subcategories, :class_name => "Category", :foreign_key => "cat_id"
end
.

categories 테이블이 보이는 경우 :

id   |   name    |  cat_id
---------------------------
1    | cat 1     | null
2    | cat 1.1   | 1
3    | cat 1.2   | 1
4    | cat 2     | null
5    | cat 1.2.1 | 3
.

Category.find(1).subcategoriescat 1.1cat 1.2 객체가있는 배열을 반환합니다.

Category.find(1).supercategorynil를 반환합니다

Category.find(3).supercategorycat 1 객체를 반환합니다

Category.find(4).supercategorynil를 반환합니다

...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top