EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jzacharuknh on May 07, 2014, 12:22:21 PM



Title: ComboGrid ASP SelectedIndexChanged
Post by: jzacharuknh 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?


Title: Re: ComboGrid ASP SelectedIndexChanged
Post by: jzacharuknh on May 09, 2014, 08:38:13 AM
Bump...

Last piece of functionality I need before buying the commercial license.


Title: Re: ComboGrid ASP SelectedIndexChanged
Post by: stworthy 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
})
}
})


Title: Re: ComboGrid ASP SelectedIndexChanged
Post by: jzacharuknh 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.


Title: Re: ComboGrid ASP SelectedIndexChanged
Post by: stworthy 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');
}
})