jQWidgets Forums

jQuery UI Widgets Forums Grid Getting value from linkrenderer

This topic contains 3 replies, has 2 voices, and was last updated by  Ivo Zhulev 8 years, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Getting value from linkrenderer #86961

    walker1234
    Participant

    I have a linkrenderer function defined as follows which basically displays jqxGrid like below(all the cell contents are hyperlinked which is not shown below):

    ___________

    
    Alphabets(s)
    ___________
    
        a
    _________
    
        B
    _________
    
       A
    _________
    
        B
    	
    	
     var linkrenderer = function(row, column, value){
    
                        if(value.indexOf('#') != -1){
    
                          value = value.substring(0,value.indexOf('#'));
                        }
                       
    
                         console.log("Inside Linkrenderer "+value );
    
                       var href = $('#alphabetPanel').jqxGrid('getcellvalue',row,"QuantityPerUnit"); // I got this QuantityPerUnit from some different post, don't know what to use here
    
                       
                      
                       return "<a href='"+ href + "''>" +value + "</a>";
    
                    
                      
    
                    }
    				
    				
    		$("#alphabetPanel").jqxGrid({
    
                       source: dataAdapter,
                       width: '122',
                       height: '170',
                      
                       
                       columns: [
                           { text: 'Alphabets(s)', datafield: 'alphabets_text',width: 100, cellsrenderer: linkrenderer}
                           
                           
                        ]
                    });

    I am trying to figure out when a user clicks on particular cell of alphabet present in the jqxGrid, how can I get the value A (when user clicks on alphabet, A).

    Because my ultimate goal is to highlight alphabet A in another text content present in jqxPanel. Both grid and panel are using the same data.

    Getting value from linkrenderer #86965

    Ivo Zhulev
    Participant

    Hi walker1234,

    You should bind to the jqxGrid cellclick event.
    Here is the demo:
    http://jsfiddle.net/jqwidgets/HB3Cb/

    Best Regards,
    Ivo

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

    Getting value from linkrenderer #86984

    walker1234
    Participant

    I am using linkrenderer as mentioned in the following post by Dimitar:(Reply #45857)

    http://www.jqwidgets.com/community/topic/customising-link-renderer-in-data-grid/

    My linkrenderer is as follows:

    var linkrenderer = function(row, column, value){
    
                        if(value.indexOf('#') != -1){
    
                          value = value.substring(0,value.indexOf('#'));
                        }
                        console.log("Inside Linkrenderer "+value );
    
                        var href = $('#columnPanel').jqxGrid('getcellvalue',row,"MyColumnName(s)");
    
                       console.log("href: "+href); // Outputs Undefined 
    
                       
    
                         return "<a href='"+ value + "''>" +value + "</a>";
    
                    
                      
    
                    }

    Questions:

    1) I couldn’t find any documentation online which has format of this line:

    `var href = $(‘#columnPanel’).jqxGrid(‘getcellvalue’,row,”MyColumnName(s)”);
    `
    I mean in the above line, do I need to specify cell instead of row ? Is it mandatory to mention MyColumnName(s) ?

    2) I am getting the value of the column in the form of link when I click it. For example , it takes me to the URL http://localhost:8080/mywebsite/A. Is it
    necessary to use cellclick instead of getcellvalue? I mean should I change it to var href = $('#columnPanel').jqxGrid('cellclick',row,"MyColumnName(s)");?

    3) Instead of linkrenderer taking me to a link and opening a new tab in the browser, I want to stay on the same page.
    I am basically looking to grab the value A upon the cellclick so that I can pass it whereever I want to. Please not that I would still like to show the
    cell values as hyperlinks. How can I modify linkrenderer in this case?

    Thanks

    Getting value from linkrenderer #86995

    Ivo Zhulev
    Participant

    Hi walker1234,

    1. Yes you do need the column name there. The second param is the row number the third one is the column.

    2@3. The linkrenderer function is about getting the value of the cell and making it an URL in the initialization of the jqxgrid. You want to get the
    value when you click on the cell right?
    Leave your linkrenderer function as it. Just bind to the ‘cellclick’ event and do your stuff there. Here is a demo:
    https://www.jseditor.io/?key=jqxgrid-cellrenderer

    Best Regards,
    Ivo

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

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

You must be logged in to reply to this topic.