EasyUI Forum
April 29, 2024, 07:29:28 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: ComboGrid ASP SelectedIndexChanged  (Read 8747 times)
jzacharuknh
Newbie
*
Posts: 3


View Profile
« on: May 07, 2014, 12:22:21 PM »

I have an asp DropDownList that has a SelectedIndexChanged server side event. I have successfully setup the combogrid on the DropDownList except that I would like the server side SelectedIndexChanged event to fire when a row is selected in the combogrid.

What are the steps for making this happen?
Logged
jzacharuknh
Newbie
*
Posts: 3


View Profile
« Reply #1 on: May 09, 2014, 08:38:13 AM »

Bump...

Last piece of functionality I need before buying the commercial license.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: May 09, 2014, 09:13:45 AM »

When a row is selected in the combogrid, the 'onChange' event fires, in which you can post some information to notify the server.
Code:
$('#cg').combogrid({
onChange:function(value){
$.post(yoururl, {value:value}, function(){
// do something here
})
}
})
Logged
jzacharuknh
Newbie
*
Posts: 3


View Profile
« Reply #3 on: May 09, 2014, 10:34:43 AM »

Hi stworthy,

I am aware of both the onChange and onSelect. My problem is that I am unable to fire the server side event within them. In the below example I have tried to add the newly selected value as the selected item in the original "select" and then firing its change function. Unfortunately, although this causes a postback it never calls the SelectedIndexChanged event.

Code:
$(document).ready(function () {
    //var currName = $('#ctl00_PageContent_CardIdFilter').attr('name');
    $('#ctl00_PageContent_CardIdFilter').combogrid({
        panelWidth: 600,
        panelHeight: 360,
        width: 250,
        mode: 'remote',
        striped: 'True',
        idField: 'CardId',
        textField: 'CardName',
        fitColumns: 'true',
        loadMsg: 'Searching...',
        pagination: 'True',
        pageSize: '10',
        onSelect: function (rowIndex, rowData) {
            var o = new Option(rowData.CardName, rowData.CardId);
            $(o).html(rowData.CardName);
            $('#ctl00_PageContent_CardIdFilter').prepend(o);
            $('#ctl00_PageContent_CardIdFilter').val(rowData.CardId);
            $('#ctl00_PageContent_CardIdFilter').change();
        },
        etc

protected override void CardIdFilter_SelectedIndexChanged(object sender, EventArgs args)
        {
            // Never gets called
        }


I believe this is because when a combogrid is created it removes the name from the original select and sets that same name to the hidden combo-value.

Code:
<select 
    onchange = "javascript:setTimeout('__doPostBack(\'ctl00$PageContent$CardIdFilter\',\'\')', 0)"
    id = "ctl00_PageContent_CardIdFilter"
    class = "Filter_Input combogrid-f combo-f"
    onkeypress = "dropDownListTypeAhead(this,false)"
    onfocus = "try{document.getElementById(&quot;__LASTFOCUS&quot;).value=this.id;}catch(e){}"
    comboname = "ctl00$PageContent$CardIdFilter"
    style = "display: none;" >
< /select>

<input type="hidden" class="combo-value" name="ctl00$PageContent$CardIdFilter" value="">

Unfortunately I am not able to call a generic (e.g. newly created) server side function as I am trying to fit this within a framework that autogenerates a lot of code - including the SelectedIndexChanged.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: May 09, 2014, 04:38:12 PM »

Please try to trigger the 'change' event in 'onChange' event of combo grid.
Code:
$('#cg').combogrid({
onChange:function(value){
$(this).trigger('change');
}
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!