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
dataEvents function parameter
28/10/2011
20:12
Avatar
violinssoundcool
Member
Members
Forum Posts: 35
Member Since:
05/02/2009
sp_UserOfflineSmall Offline

I have a chained select box in a form edit window. I have a function that populates the second select box (scategory) based on the value of the first one (category). This function is based on this example.

function subcategory_selectbox(e){
    var selected_category = parseInt($(e.target).val(),10);
    var account = $('#account').val();
    $.ajax({
        url:"SELBX_SCAT.php?cat="+selected_category+"&acct="+account,
        dataType:"html",
        success:function(newOptions){
            var form = $(e.target).closest("form.FormGrid");
            $("select#scategory.FormElement",form[0]).html(newOptions);
        }
    });
}

I attach it to the colModel like this:

{name:'category', editoptions:{
    dataUrl:'SELBX_CAT.php?account='+$('#account').val(),
    dataEvents:[{
        type:"change",
        fn:function(e){
            subcategory_selectbox(e);
        }
    }]
},…

This works perfectly, but I can't figure out how to pass that same variable "e" from other places. For instance, I have a beforeShowForm function that I would like to be able to call subcategory_selectbox() from, but I don't know what to pass. How do I pass the same variable "e" as the dataEvents function does?

Also, on my account select box, I have the following function to trigger onChange:

$('#account').change(function(){
    $('#transGrid').setColProp('category',{
        editoptions:{
            dataUrl:'SELBX_CAT.php?account='+$('#account').val()
        }
    });
    $('#transGrid').setGridParam({postData:{account:$('#account').val()}});
    $('#transGrid').trigger('reloadGrid');
});

This does the trick as far as basing the values of the category select box on the currently selected account, but it no longer executes the dataEvents function. I even tried including the same dataEvents code from the second code snippet in this post, but it didn't work either. How can I keep the category select box based on the account select box without eliminating the dataEvents function?

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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