jQWidgets Forums

jQuery UI Widgets Forums ASP .NET MVC Change the color of the buttons only in the column of buttons Edit

This topic contains 2 replies, has 2 voices, and was last updated by  Novato 6 years, 1 month ago.

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

  • Novato
    Participant

    Hi, I’m doing an edit of my grid with popup like this example

    I want to change the background color only of my buttons in the edit column. So far I change the color of the buttons but I also change the color of the buttons of the grid pager.

    Is there any solution for this?

    Thank you.

    
    
     <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" />
        <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.pager.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> 
        <script type="text/javascript" src="../../jqwidgets/jqxnumberinput.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxinput.js"></script>
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript" src="generatedata.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                // prepare the data
                var data = generatedata(200);
                var source =
                {
                    localdata: data,
                    datatype: "array",
                    datafields:
                    [
                        { name: 'firstname', type: 'string' },
                        { name: 'lastname', type: 'string' },
                        { name: 'productname', type: 'string' },
                        { name: 'quantity', type: 'number' },
                        { name: 'price', type: 'number' }
                    ],
                    updaterow: function (rowid, rowdata, commit) {
                        // synchronize with the server - send update command
                        // call commit with parameter true if the synchronization with the server is successful 
                        // and with parameter false if the synchronization failder.
                        commit(true);
                    }
                };
               
             
                var dataAdapter = new $.jqx.dataAdapter(source);
                var editrow = -1;
                
                
                // initialize jqxGrid
                $("#grid").jqxGrid(
                {
                    width: getWidth('Grid'),
                    source: dataAdapter,
                    pageable: true,
                    autoheight: true,
                    columns: [
                      { text: 'First Name', datafield: 'firstname', width: 200 },
                      { text: 'Last Name', datafield: 'lastname', width: 200 },
                      { text: 'Product', datafield: 'productname', width: 190 },
                      { text: 'Quantity', datafield: 'quantity', width: 90, cellsalign: 'right' },
                      { text: 'Price', datafield: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2' },
                      
                      //Column buttons edit
                      { text: 'Editar', datafield: 'Editar', columntype: 'button', cellsrenderer: function () {
                      
                      //Here I apply the color to the buttons but this color also applies to the paging buttons and I only want those in the button column edit
                     $("#grid .jqx-button").css('background-color', '#7A3BFF')
    
                      }, buttonclick: function (row) {
                         // open the popup window when the user clicks a button.
                         editrow = row;
                         var offset = $("#grid").offset();
                         $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
                         // get the clicked row's data and initialize the input fields.
                         var dataRecord = $("#grid").jqxGrid('getrowdata', editrow);
                         $("#firstName").val(dataRecord.firstname);
                         $("#lastName").val(dataRecord.lastname);
                         $("#product").val(dataRecord.productname);
                         $("#quantity").jqxNumberInput({ decimal: dataRecord.quantity });
                         $("#price").jqxNumberInput({ decimal: dataRecord.price });
                         // show the popup window.
                         $("#popupWindow").jqxWindow('open');
                     }
                     }
                    ]
                });
    
    

    Hristo
    Participant

    Hello Novato,

    You could use the cellclassname member of the column with the buttons.
    Please, take a look at this example.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    Novato
    Participant

    Hi Hristo, thank you very much it works perfect

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

You must be logged in to reply to this topic.