jQWidgets Forums

jQuery UI Widgets Forums Grid rowclick but not nested

This topic contains 7 replies, has 3 voices, and was last updated by  Peter Stoev 11 years, 5 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • rowclick but not nested #21400

    rushed
    Member

    Hello

    $(grid).on('rowclick', function (event) {
     alert(event.args.toSource());
    });

    if i click on the row i want an alert.
    but if i click on the nested grid i want no alert.

    Thanks for helping

    rowclick but not nested #21402

    Peter Stoev
    Keymaster

    Hi,

    Please, post a complete sample which demonstrates that. I am not sure also what is “grid” in your code. If it is ID, it should be “#grid”

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    rowclick but not nested #21404

    rushed
    Member

    Some copy & paste Problems http://justpaste.it/2nsl < < code here

    
    DEMO
    
    
    
    
    
    
    
    
    
    
        
        
    
     
    
    
    
    
    
    
    
     
     
     
     
    
    
    
     
     
    
    
    
         
    
    
    
    
    
      
    
    
    
    	$(document).ready(function () {
    		
    		var initrowdetails = function (index, parentElement, gridElement, datarecord) {
    			var getAdapter2 = function () {
    				var url2 = "core/cont/json/textbausteine_json.php";
    					// prepare the data
    				var source2 ={
    				datatype: "json",
    				datafields: [
    						{ name: 'x1', type:'string'},		
    						{ name: 'x2', type:'html'}	,
    						{ name: 'x3', type:'string'}	
    					],
    					id: 'id',
    					url: url2,
    					root: 'data'
    				};//source
    											 
    				var dataAdapter2 = new $.jqx.dataAdapter(source2);
    				return dataAdapter2;
    			}//getAdapter
    			
    			$($(parentElement)).html('
    '); $($(parentElement).children()[0]).jqxGrid({ /* Sprachsteine */ source: getAdapter2(), theme: theme, columns: [ { text: 'Sprache', datafield:'x1', width: 80 ,cellsalign: 'center', align: 'center' }, { text: 'Betreff', datafield:'x2', width: 120 ,cellsalign: 'center', align: 'left'}, { text: 'Text', datafield:'x3', width: 400 ,cellsalign: 'center', align: 'left'} ], }); }//initrow var grid = "#tabelle_textbausteine"; var theme = getDemoTheme(); var getAdapter = function () { var url = "core/cont/json/textbausteine_json.php"; var source ={ datatype: "json", datafields: [ { name: 'z1', type: 'int' }, { name: 'z2', type: 'string' }, { name: 'z3', type: 'text' } ], id: 'id', url: url, root: 'data' }; var dataAdapter = new $.jqx.dataAdapter(source); return dataAdapter; } $(grid).on('rowdoubleclick', function (event) { alert(1); //should NOT alert when i click on the nested row }); $(grid).jqxGrid({ width: 1200, source: getAdapter(), theme: theme, rowdetails: true, rowdetailstemplate: { rowdetails: "
    ", rowdetailsheight: 200 }, ready: function () { }, initrowdetails: initrowdetails, pageable: true, editable: false, selectionmode: 'multiplerowsextended', columns: [ { text: 'Webshop', datafield: 'z1', width: 150 }, { text: 'Textbaustein', datafield: 'z2', width: 200 }, { text: 'Gruppe', datafield: 'z3', width: 200 } ] }); });
    rowclick but not nested #21410

    Peter Stoev
    Keymaster

    Hi,

    Binding to the “grid” events will raise events only for the Master Grid. If you want to bind to a nested Grid, then you should do that in the “initrowdetails” function.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    rowclick but not nested #21412

    rushed
    Member

    yeah but i want an alert from the master grid event and from the nested grid event, but not the same alert

    if i now click on the nested click row i get the event alert from the master grid.

    rowclick but not nested #21413

    Peter Stoev
    Keymaster

    Hi,

    Please, keep in mind that there is event bubbling. So binding to the “rowclick” of a nested Grid will raise it for the master Grid, too. I suppose that you will need to add some boolean flags in your code.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    rowclick but not nested #30561

    I’m having onrowclick event handler on parent grid, and it gets fired even when i click nested grid (part of row detail) – I never boudn this click event to it.

    I think that is a bug, or is there a way to determine the bounded grid rather then the clicked grid, from event?

    rowclick but not nested #30563

    Peter Stoev
    Keymaster

    Hi Milos Broulik,

    That is not a bug. The nested Grid raises a “rowclick” event and as you know events in Javascript have Bubble behavior so you will catch the event in the parent Grid’s “rowclick” handler as well. The solution is simple – bind to the “rowclick” of the nested Grid and in the event handler return false.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.