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_TopicIcon
Get Select field options in dependence of a second select field
10/11/2011
12:17
Avatar
kramoo6
Austria
Member
Members
Forum Posts: 3
Member Since:
09/11/2011
sp_UserOfflineSmall Offline

Hallo,

i use dataUrl to get the html for the select field from the DB.

colModel :[
       {name:'projektname', index:'projektname', width:160,
                            editable: true,
                            edittype:"select",
                            editoptions:{dataUrl:'/backlink/get-projektname'} //, defaultValue:'Intime'}
                            //formoptions:{ rowpos:3,elmprefix:"    " }
            },

now i have a second select field. This should get the html for the field from DB in dependence from the first one.

{name:'unterprojektname', index:'unterprojektname', width:160,
                            editable: true,
                            edittype:"select",
                            editoptions:{dataUrl:'/backlink/get-unterprojektname?selectfieldone=value'} //, defaultValue:'Intime'}
            },

How can I get the value of the first select field to the dataUrl of the second select field? Or is there another way?

Thanks.

11/11/2011
17:54
Avatar
kramoo6
Austria
Member
Members
Forum Posts: 3
Member Since:
09/11/2011
sp_UserOfflineSmall Offline

Ok it works.

I only have one probleme.

If i edit a row in the form it shows me the right value of the first select field but the wrong value of the second depended select field.

In the second select field it use the first <option> entry.

If i use the buttons next i get the next row and the right value for the second select field.

colModel :[

{name:'projektname', index:'projektname', width:160, sorttype:"string", edittype:"select",  editoptions:{"value":selectfeldProjektname['responseText'],"separator":":"}, editable:true },

{name:'unterprojektname', index:'unterprojektname', width:160, sorttype:"string",edittype:"select",editoptions:{"value":" :select"},editable:true},

….

"beforeShowForm":function(formid)
    {
  // get the value of the country
    var cntryval = $("#projektname",formid).val();
    jQuery("#unterprojektname",formid).html("<option>Select</option>");
    if(cntryval) {
      // if the value is found try to use ajax call to obtain the citys
        // please look at file file city.php
        jQuery.ajax({
            url: '/backlink/get-unterprojektname',
            dataType: 'html',
            //async: false,
            data: {q:cntryval},
            success : function(response)
            {
                sv="";
                var sr = jQuery("#list").jqGrid('getGridParam','selrow');
                console.log (sr);
                if(sr)
                {
                  // get the selected city from grid
                    sv = jQuery("#list").jqGrid('getCell',sr,'unterprojektname');
                    
                
                    // empty the select and put the new selection
                    jQuery("#unterprojektname",formid).html("").append(response);
                    if(sv)
                    {
                        console.log (sv);
                    // select the city value
                        jQuery("#unterprojektname",formid).val(sv).removeAttr("disabled");
                    }
                }
            }
        });
    } else {
        jQuery("#unterprojektname",formid).attr("disabled","disabled");
    }
    },

console.log (sr) = 4

console.log (sv) = oekostrom

request from url: '/backlink/get-unterprojektname' = <option value='stromrechner-vergleich'>stromrechner-vergleich</option>
<option value='oekostrom'>oekostrom</option>….

Html from second select field:

<select role="select" id="unterprojektname" name="unterprojektname" size="1″ class="FormElement">
<option value="stromrechner-vergleich">stromrechner-vergleich</option>
<option value="oekostrom">oekostrom</option>
….
</select>

What can be wrong??

11/11/2011
18:10
Avatar
kramoo6
Austria
Member
Members
Forum Posts: 3
Member Since:
09/11/2011
sp_UserOfflineSmall Offline

Ohh sorry!!

In the variable sv it gets from the cell was a space at the end of the string.

Know it works !

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
46 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