jQWidgets Forums

jQuery UI Widgets Forums Grid Passing an ID Value to a custom url

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  kavvson 8 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Passing an ID Value to a custom url #84611

    suadik
    Participant

    Am trying to pass a user_id value to a custom url using the JQWidgets library any help please. Am actual loading the data from a database converted to JSON. The variable “data” is how my records looks like. The user_id value does not show as part of the url. Below is my code

    <div id='jqxWidget'>
       <div id="jqxgrid"></div>
     </div>
    
    <script type="text/javascript">
            $(document).ready(function ()
            {
                var data = [{user_id:100,user_name:"sam",first_name:"doe"}];
    
        var source =
            {
                datatype: "json",
                datafields:
                [
                    { name: 'user_id', type: 'string' },
                    { name: 'user_name', type: 'string' },
                    { name: 'first_name', type: 'string' },
                    { name: 'action'}
                ],
                id: 'user_id',
                root: 'Rows',
            };
                var dataAdapter = new $.jqx.dataAdapter(source);
    
                // create jqxgrid.
                $("#jqxgrid").jqxGrid(
                {
                    width: 1000,
                    height: 450,
                    theme: 'light',
                    source: dataAdapter,
                    selectionmode: 'multiplerowsextended',
                    sortable: true,
                    pageable: true,
                    pageSize: 20,
                    autoHeight: true,
                    filterable: true,
                    pagesizeoptions: ['20', '40', '80','200'],
                    altrows: true,
                    columns: [
                      { text: 'User ID', datafield: 'user_id', width: 100 },
                      { text: 'User Name', datafield: 'title', width: 70, cellsformat: 'yyyy-MM-dd'},
                      { text: 'First Name', datafield: 'first_name', width: 150, cellsformat: 'F2', cellsalign: 'left' },
                      { text: 'Action', datafield: 'action',cellsrenderer: renderer,width:130  }
                    ]
                });
            });
            var renderer = function (action) {
              return '<span style="padding:5px;" >'+'<a href="update_user?id=data.user_id" class="btn btn-default btn-xs" style="margin-top:3px;"><i class="fa fa-check-square-o"></i>Update user</a>'+'</span>';
           }
    
        </script>
    Passing an ID Value to a custom url #84615

    kavvson
    Participant

    I am using such thing

                var linkrenderer = function(row, columnfield, value, defaulthtml, columnproperties){
    		editrow = row;
                    var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
                    var ffrTitle = dataRecord.{{COLUMN}}; // in your case user_id
    		return '<a href="LINK'+ffrTitle+'" /></a>';
                }
    
    and in columns 
    { text: 'Action', datafield: 'ac', cellsrenderer: linkrenderer},
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.