Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

ruby on rails - Ordering category select menu alphabetically with awesome_nested_set -


using awesome_nested_set rails 3, i've created hierarchical categories system. display category selector in view, i've used following code:

<%= form.select :parent_id, options_for_select(nested_set_options(category, @category) {|i| "#{'-' * i.level} #{i.name}" }.unshift(["no parent", nil]), @category.parent_id) %>

i'm attempting order categories in alphabetical order, on level level basis. if change nested_set_options(category, @category) nested_set_options(category.order("name"), @category) reorder whole categories list name; want reorder children of each node alphabetically name.

for example, want resulting select menu ordered this:

animal - bird -- chicken -- hawk - fish -- cod -- goldfish -- trout - mammal -- cat -- primate --- chimpanzee --- human -- zebra plant - tree 

although unfamiliar awesome_nested_set, can call order twice in rails 3.

category.order(:level).order(:name) 

this should order category each level , name within each level. also, can throw on default scope within model.

class category < activerecord::base   default_scope order('level, name')   ... end 

orders great default scope because don't effect default values.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -