Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
editable dynamic selects using dataURL
29/01/2012
02:43
Avatar
illiquent
Member
Members
Forum Posts: 5
Member Since:
29/01/2012
sp_UserOfflineSmall Offline

hi.

i've got a jGrid reading data in with json, with an Item, Category, SubCategory.

The goal is to have the category and subcategory be editable, and the subcategory select should depend on category.

ie if a category is changed, the subcategories refresh. on the subcategory change, the page should post the data.

I think that using the formatter: "select" option might be what I want, but I'm not finding any useful documentation or examples on it.

here's what I have in my colModel

colModel:[
                {name:'ID',index:'ID', width:30, key:true, hidden:true},
                {name:'ITEMNAME',index:'ITEMNAME', width:200},
                {name:'CAT_ID',index:'CAT_ID', width:150, editable: true,edittype:"select",formatter: "select",
                editoptions: { dataUrl: '/admin/cats.cfm'} },
                {name:'SUBCAT_ID',index:'SUBCAT_ID', width:150,editable: true,edittype:"select",
                editoptions: { dataUrl: '/admin/cats.cfm?subcat=1'} },
            ],

when i use formatter: select, the select box is blank

when I don't, they work fine.

I realize the code above isn't going to do what I need, but I'm hoping it might show what I'm trying to do.

Is there an example in the docs themselves for dynamic select boxes?

I've seen lots of suggested solutions in forums, but none of them make sense or work for my situation.

I know this is a common task, so I'm surprised to see its not better documented or why so many people seem confused on it.

29/01/2012
06:23
Avatar
illiquent
Member
Members
Forum Posts: 5
Member Since:
29/01/2012
sp_UserOfflineSmall Offline

i found the solution on another post.

thanks tony!

here's the version I used:

$("document").ready(function() {
        var lastsel2
        jQuery("#list2").jqGrid({
            url:'/beta/prodSelect.cfc?method=getAllGrid',
            width:"auto",
            height:"auto",
            datatype: "json",
            colNames:['ID','ITEMNAME', 'CAT_ID','SUBCAT_ID'],
            colModel:[
                {name:'ID',index:'ID', width:30, key:true, hidden:true},
                {name:'ITEMNAME',index:'ITEMNAME', width:200},
                {name:'CAT_ID',index:'CAT_ID', width:150, editable: true,edittype:"select",
                editoptions: {
                dataUrl: '/admin/cats.cfm',
                dataEvents :[

{ type: 'change', fn: function(e) {

var thisval = $(e.target).val();

$.get('cats.cfm?subcat=1&topCatID='+thisval, function(data)

{ var res = $(data).html();

var id = jQuery("#list2").jqGrid('getGridParam', 'selrow');
var t = '#' + id + '_SUBCAT_ID';
$(t).html(res);
}); // end get

}//end func

} // end type

] // dataevents
                
                } },
                {name:'SUBCAT_ID',index:'SUBCAT_ID', width:150,editable: true,edittype:"select",
                editoptions: { dataUrl: '/admin/cats.cfm?subcat=1'} },
            ],
            
        onSelectRow: function(id){
      if(id && id!==lastsel2){
        jQuery('#list2').restoreRow(lastsel2);
        jQuery('#list2').editRow(id,true,'1');
          lastsel2=id;
              }
            },
            rowNum:30,
            rowList:[30,60,90],
            pager: '#pager2',
            sortname: 'thisid',
            viewrecords: true,
            sortorder: "asc",
            editurl: "/admin/qry_itemCorrect.cfm",
            
            caption:"Your Items"
            });
        
    
        
        });

29/02/2012
00:48
Avatar
saw
New Member
Members
Forum Posts: 1
Member Since:
23/02/2012
sp_UserOfflineSmall Offline

Hi,

I'm trying to set up dynamic selects with coldfusion too. Your example looks good. What is on your admin/cats.cfm?subcat=1' page? I'm trying to use a cfquery in a function on a cfc page. but it's not working yet.

Thank you

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information