jQWidgets Forums

Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • in reply to: Sort custom Sort custom #82268

    amatost
    Participant

    Thanks, Dimitar

    but unfortunately I am not an experienced programmer, I have to implement this code?:

    
                var customsortfunc = function (column, direction) {
                    var sortdata = new Array();
    
                    if (direction == 'ascending') direction = true;
                    if (direction == 'descending') direction = false;
    
                    if (direction != null) {
                        for (i = 0; i < data.length; i++) {
                            sortdata.push(data[i]);
                        }
                    }
                    else sortdata = data;
    
                    var tmpToString = Object.prototype.toString;
                    Object.prototype.toString = (typeof column == "function") ? column : function () { return this[column] };
                    if (direction != null) {
                        sortdata.sort(compare);
                        if (!direction) {
                            sortdata.reverse();
                        }
                    }
                    source.localdata = sortdata;
                    $("#jqxgrid").jqxGrid('updatebounddata', 'sort');
                    Object.prototype.toString = tmpToString;
                }
    
                // custom comparer.
                var compare = function (value1, value2) {
                    value1 = String(value1).toLowerCase();
                    value2 = String(value2).toLowerCase();
    
                    try {
                        var tmpvalue1 = parseFloat(value1);
                        if (isNaN(tmpvalue1)) {
                            if (value1 < value2) { return -1; }
                            if (value1 > value2) { return 1; }
                        }
                        else {
                            var tmpvalue2 = parseFloat(value2);
                            if (tmpvalue1 < tmpvalue2) { return -1; }
                            if (tmpvalue1 > tmpvalue2) { return 1; }
                        }
                    }
                    catch (error) {
                        var er = error;
                    }
    
                    return 0;
                };
    

    could you kindly give me an example related to my case?

    Best regards,
    Amato


    amatost
    Participant

    Hi Ivo,

    you can see an example of data.php code?

    thanks advance,

    Best Regards,
    Amato


    amatost
    Participant

    Thanks for answer Ivo,

    I need to insert directly into mysql db table and then do a refresh,

    sorry but the example does not work?

    Best Regards,
    Amato


    amatost
    Participant

    Hi Dimitar,

    actually this code with id_squadra was only a test as:

    
                      }, buttonclick: function (row) {
                         var editrow = row;
                         var dataRecord = $("#jqxgrid1").jqxGrid('getrowdata', editrow);
                         var id_squadra = $id_squadra;
                         alert(id_squadra);
    

    you can see in the first post the code that I had put was correct but it worked, but now works with your directives.

    Thanks for your patience and professionalism you showed.

    how do I close the discussion resolved?

    Best regards,
    Amato


    amatost
    Participant

    There is no error, that does not work is the piece of code that

                      }, buttonclick: function (row) {
                         var editrow = row;
                         var dataRecord = $("#jqxgrid1").jqxGrid('getrowdata', editrow);
                         alert(dataRecord.id_giocatore);
    

    but beware, if I call this same code over via an external html file works, I believe that this is due to the interpretation of the url

    anyway that’s all the code:

    
    <?php
    $user = JFactory::getUser();
    if (!$user->guest) {
       $utente=$user->id;
    }
    
    $db = JFactory::getDBO();
              $query = $db->getQuery(true);
              $query->select('id_squadra, sq_id_utente, sq_nome_squadra, sq_crediti_iniziali, sq_crediti_iniziali, sq_crediti_residui, sq_valore_rosa');
              $query->from('fcw_squadre');
              $query->where('sq_id_utente='.$utente.'');
              $db->setQuery((string)$query);
    
    $datasq=$db->loadObjectList();
    
    echo "<div class=moduleclass_sfx $params->get('moduleclass_sfx', '') >";
    echo '<form action="" method="post">';
    echo "<select name='select_squadra'>";
    echo "<option value=''>Seleziona la squadra</option>";
         foreach ( $datasq  as $i=>$datasq): 
               echo "<option value='$datasq->id_squadra'>$datasq->sq_nome_squadra</option>";
        endforeach;
    echo "</select>";
    echo "<input id='gobutton' type='submit' name='submit' value='Conferma'/>";
    echo "</form>";
    echo "</div>";
    
    if(isset($_POST['select_squadra'])){
        $select_squadra = $_POST['select_squadra'];
        //echo "<div class='divbottoni'>";
        //echo "<a href='http://www.fantacalcioworld.it/libraries/jqx/compra_portiere.html?id_squadra=$select_squadra' target='_blank' rel='lightbox' class='jcepopup noicon link-button button-green'  data-mediabox-group='lightbox' data-mediabox-width='550' style='margin-bottom: 10px;'>Compra un Portiere</a>";	
        //echo "</div>";
    }
    ?>
    
    <!DOCTYPE html>
    <html lang="it">
    <head>
    
    <style>
    div#jqxgrid{
        margin-left:auto;
        margin-right:auto;
        float:left;
    
    }
    div#jqxgrid1{
        float:right;
    }
    
    input#gobutton{
    cursor:pointer; /*forces the cursor to change to a hand when the button is hovered*/
    padding:2px 15px; /*add some padding to the inside of the button*/
    margin: 10px;
    margin-bottom: 22px;
    background:#35b128; /*the colour of the button*/
    border:1px solid #33842a; /*required or the default border for the browser will appear*/
    /*give the button curved corners, alter the size as required*/
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    /*give the button a drop shadow*/
    -webkit-box-shadow: 0 0 4px rgba(0,0,0, .75);
    -moz-box-shadow: 0 0 4px rgba(0,0,0, .75);
    box-shadow: 0 0 4px rgba(0,0,0, .75);
    /*style the text*/
    color:#f3f3f3;
    font-size:1.1em;
    
    .divBottoni button{
    cursor:pointer; /*forces the cursor to change to a hand when the button is hovered*/
    padding:2px 15px; /*add some padding to the inside of the button*/
    margin: 10px;
    margin-bottom: 22px;
    background:#35b128; /*the colour of the button*/
    border:1px solid #33842a; /*required or the default border for the browser will appear*/
    /*give the button curved corners, alter the size as required*/
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    /*give the button a drop shadow*/
    -webkit-box-shadow: 0 0 4px rgba(0,0,0, .75);
    -moz-box-shadow: 0 0 4px rgba(0,0,0, .75);
    box-shadow: 0 0 4px rgba(0,0,0, .75);
    /*style the text*/
    color:#f3f3f3;
    font-size:1.1em;
        display:inline;
        margin : 0.1%;  	
     }
    }
    
    input#gobutton:hover, input#gobutton:focus{
    background-color :#399630; /*make the background a little darker*/
    /*reduce the drop shadow size to give a pushed button effect*/
    -webkit-box-shadow: 0 0 1px rgba(0,0,0, .75);
    -moz-box-shadow: 0 0 1px rgba(0,0,0, .75);
    box-shadow: 0 0 1px rgba(0,0,0, .75);
    }
    </style>
    
    </head>
    <body class='default'>
       <div id="jqxgrid"></div>
       <div id="jqxgrid1"></div>
    </body>
    </html>
    	
        <script type="text/javascript">
            jQuery(document).ready(function ($) {
                // prepare the data
                
                var source = {
                    datatype: "json",
                    datafields: [
                        { name: 'rs_ruolo', type: 'string'},
                        { name: 'gt_nome', type: 'string'},
                        { name: 'sqc_logo', type: 'string'},
                        { name: 'sqc_squadra', type: 'string'},
                        { name: 'rs_valore', type: 'int'}
                    ],
                    url: '/libraries/jqx/rosa.php?select_squadra=<?php echo $select_squadra;?>',
    		cache: false
                };
    
                var imagerenderer = function (row, datafield, value) {
                    return '<img style="margin-left: 5px; margin-top: 5px;" height="35" width="auto" src="' + value + '"/>'; };
    
                var dataAdapter = new $.jqx.dataAdapter(source);
    			
    	    $("#jqxgrid").jqxGrid( {
                    width: 610,
                    height: 600,
                    source: dataAdapter,
                    theme: 'base',
                    rowsheight: 35,
                    columns: [
                      { text: 'Ruolo', datafield: 'rs_ruolo', width: 50},
                      { text: 'Nome', datafield: 'gt_nome', width: 180 },
                      { text: '', datafield: 'sqc_logo', width: 50, cellsrenderer: imagerenderer },
                      { text: 'Squadra', datafield: 'sqc_squadra', width: 180 },
                      { text: 'Valore', datafield: 'rs_valore', width: 50 },
                      { text: 'Azione', datafield: 'Edit', width: 100, columntype: 'button', cellsrenderer: function () { 
                         return "Vendi";
                      }, buttonclick: function (row) {
                         editrow = row;
                         alert("premuto");
                         }
                      }
                  ]
    
                });        
            });
        </script>
    
        <script type="text/javascript">
            jQuery(document).ready(function ($) {
                // prepare the data
                
                var source1 = {
                    datatype: "json",
                    datafields: [
                        { name: 'id_giocatore', type: 'string'},
                        { name: 'gt_nome', type: 'string'},
                        { name: 'gt_squadra', type: 'string'},
                        { name: 'gt_quota', type: 'int'}
                    ],
                    url: '/libraries/jqx/portieri.php',
    		cache: false
                };
    
                var imagerenderer = function (row, datafield, value) {
                    return '<img style="margin-left: 5px; margin-top: 5px;" height="35" width="auto" src="' + value + '"/>'; };
    
                var dataAdapter = new $.jqx.dataAdapter(source1);
                var editrow = -1;
    			
    	    $("#jqxgrid1").jqxGrid( {
                    width: 500,
                    height: 600,
                    source: dataAdapter,
                    theme: 'base',
                    selectionmode: 'singlerow',
                    rowsheight: 35,
                    columns: [
                      { text: 'Id', datafield: 'id_giocatore', width: 50},
                      { text: 'Nome', datafield: 'gt_nome', width: 150 },
                      { text: 'Squadra', datafield: 'gt_squadra', width: 150 },
                      { text: 'Valore', datafield: 'gt_quota', width: 50 },
                      { text: 'Azione', datafield: 'Edit', width: 80, columntype: 'button', cellsrenderer: function () { 
                         return "Compra";
                      }, buttonclick: function (row) {
                         var editrow = row;
                         var dataRecord = $("#jqxgrid1").jqxGrid('getrowdata', editrow);
                         var id_squadra = $id_squadra;
                         alert(id_squadra);
                         //alert("Premuto");
                         }
                      }
                  ]
    
                });        
            });
        </script>
    

    If you want you can give the site access to private Credentials

    thanks.


    amatost
    Participant

    thank you very much for your reply,
    I did everything exactly as you explained, but I have not yet solved the problem described before

    any idea?

    Best Regards,
    Amato

    in reply to: get row data not working get row data not working #79741

    amatost
    Participant

    Thanks Hristo,
    I corrected as I have indicated, but I did not understand the point 2, what purpose exactly?
    Because I believe that the problem is in step 2, because if the sample files directly from the browser works perfectly, while I can not make it work. Could you explain the concept of accuracy of the url?

    Thank you for your availability

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