This topic contains 2 replies, has 2 voices, and was last updated by  manikandan.k 8 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    CellRenderer Posts
  • CellRenderer #73126

    manikandan.k
    Participant

    hi,

    How to display two datafields values in single field. my code is given below..

    code

    var source = {
    datatype: “json”,
    datafields: [
    { name: ‘lcms_lliSourceID’, type: ‘number’ },
    { name: ‘lcms_hierarchyID’, type: ‘string’ },
    { name: ‘lcms_source’, type: ‘string’ },
    { name: ‘lcms_subAgreement’, type:’ string’},
    { name: ‘lcms_city’, type:’ string’},
    { name: ‘lcms_state’, type:’ string’},
    { name: ‘lcms_country’, type:’ string’},
    { name: ‘lcms_foreign’, type:’ string’},
    { name: ‘lcms_feed’, type:’ string’},
    { name: ‘lcms_2013printCirc’, type:’ string’},
    { name: ‘AcqSrcDataTesting’, type: ‘string’}
    ],

    cache: false,
    url: ‘index.php?rt=login/getPublishersDetails/’+subAgreementId,
    updaterow: function (rowid, rowdata, commit) {
    commit(true);
    }
    };
    var a;
    var cellsrenderer1=function(row,value){
    a=value;
    }

    var dataAdapter = new $.jqx.dataAdapter(source);

    $(“#publisherDetails”).jqxGrid(
    {
    width: 598,
    source: dataAdapter,
    pageable: true,
    pagesize: 12,
    showfilterrow: true,
    filterable:true,
    columns: [
    { text: ‘Source’, datafield: ‘lcms_source’, width: ‘80%’, pinned: true,
    cellsrenderer :function (row, columnfield, value, defaulthtml, columnproperties) {
    return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘;”>’ + value + “</span><input type=’image’ title=’View AcquiredSource’ alt=’icon’ src=’images/publication.png’ onClick=’acquiredDetail(“+row+”)’ class=’add_button’ style=’float:right;margin-right:10px;’><input type=’image’ title=’View Mastersource’ src=’images/master.png’ onClick=’masterSourceDetails(“+row+”)’ class=’add_button’ style=’float:right;margin-right:7px;’><input type=’image’ title=’Edit Mastersource’ src=’images/edit1.png’ onClick=’editdMasterSrcviaAgreement(“+row+”)’ class=’add_button’ style=’float:right;margin-right:7px;’><input type=’image’ title=’Edit AcquiredSource’ src=’images/edit2.png’ onClick=’editdAcqSrcviaAgreement(“+row+”)’ class=’add_button’ style=’float:right;margin-right:7px;’>”;
    }
    },{
    text:’value’,datafield:’AcqSrcDataTesting’,width:’20%’,cellsrenderer:cellsrenderer1
    }
    ]
    });

    I need display the images based on the second Column value.
    if value=1 then display some images otherwise hide the image.
    can anyone help plese…
    thanks

    CellRenderer #73131

    Dimitar
    Participant

    Hi manikandan.k,

    Here is an example. We hope it is helpful to you:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                // prepare the data
                var data = new Array();
                var firstNames =
                [
                    "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene"
                ];
                var lastNames =
                [
                    "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier"
                ];
                var productNames =
                [
                    "Black Tea", "Green Tea", "Caffe Espresso", "Doubleshot Espresso", "Caffe Latte", "White Chocolate Mocha", "Cramel Latte", "Caffe Americano", "Cappuccino", "Espresso Truffle", "Espresso con Panna", "Peppermint Mocha Twist"
                ];
                var priceValues =
                [
                    "2.25", "1.5", "3.0", "3.3", "4.5", "3.6", "3.8", "2.5", "5.0", "1.75", "3.25", "4.0"
                ];
                for (var i = 0; i < 10; i++) {
                    var row = {};
                    var productindex = Math.floor(Math.random() * productNames.length);
                    var price = parseFloat(priceValues[productindex]);
                    var quantity = 1 + Math.round(Math.random() * 10);
                    row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
                    row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)];
                    row["productname"] = productNames[productindex];
                    row["price"] = price;
                    row["quantity"] = quantity;
                    row["total"] = price * quantity;
                    data[i] = row;
                }
                var source =
                {
                    localdata: data,
                    datatype: "array"
                };
                var dataAdapter = new $.jqx.dataAdapter(source, {
                    loadComplete: function (data) { },
                    loadError: function (xhr, status, error) { }
                });
                $("#jqxgrid").jqxGrid(
                {
                    width: 380,
                    autoheight: true,
                    source: dataAdapter,
                    columns: [
                      { text: 'Name', datafield: 'firstname', width: 200, cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {
                          var lastName = dataAdapter.records[row].lastname;
                          return '<span style="margin: 4px; float: ' + columnproperties.cellsalign + ';">' + value + ' ' + lastName + '</span>';
                      }
                      },
                      { text: 'Product', datafield: 'productname', width: 180 }
                    ]
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
            <div id="jqxgrid">
            </div>
        </div>
    </body>
    </html>

    Best Regards,
    Dimitar

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

    CellRenderer #73137

    manikandan.k
    Participant

    Thanks Dimitar,

    Its working…..

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

You must be logged in to reply to this topic.