Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
i can only select the first row
15/01/2011
02:05
Avatar
Coolman1974
New Member
Members
Forum Posts: 1
Member Since:
15/01/2011
sp_UserOfflineSmall Offline

Hello together,

i have implementated the simple democode to show a jqGrid with jQuery in a HTML page.

The data type of the grid is json.

i collect the data from a firebird database of a php script.

here the html code:

Code:

...
<div id="pagecontrol-opliste-tabelle">
    <table id="table-liste">
    </table>
    <div id="pager-liste">
    </div>
</div>
...

here is the javascript code:

Code:

$(document).ready(function(){
    $("#pagecontrol-opliste").tabs();
   
    $("#table-liste").jqGrid({
        url: 'Sql.php',
        datatype: "json",
        colNames: ['Lfd. Nr', 'Kategorie', 'Kunde', 'Stichwort', 'Ersteller', 'Bearbeiter', 'Status'],
        colModel: [{
            name: 'lfdnr',
            index: 'lfdnr',
            width: 55
        }, {
            name: 'kategorie',
            index: 'kategorie',
            width: 90
        }, {
            name: 'kunde',
            index: 'kunde',
            width: 100
        }, {
            name: 'stichwort',
            index: 'stichwort',
            width: 80
        }, {
            name: 'ersteller',
            index: 'ersteller',
            width: 80
        }, {
            name: 'bearbeiter',
            index: 'bearbeiter',
            width: 80
        }, {
            name: 'status',
            index: 'status',
            width: 150,
            sortable: false
        }],
        rowNum: 10,
        rowList: [10, 20, 30],
        pager: '#pager-liste',
        sortname: 'lfdnr',
        viewrecords: false,
        sortorder: 'asc',
        caption: "OP Liste",
        scrollrows: true
    });
   
    $("#table-liste").jqGrid('navGrid', '#pager-liste', {
        edit: false,
        add: false,
        del: false
    });    
});

here is the php code:

Code:

<?php
    $page = $_GET['page']; // get the requested page
    $limit = $_GET['rows']; // get how many rows we want to have into the grid
    $sidx = $_GET['sidx']; // get index row - i.e. user click to sort
    $sord = $_GET['sord']; // get the direction
    if(!$sidx) $sidx =1;
    
    // connect to the database
    $dbh = ibase_connect ('localhost:C:xampphtdocsOPManagerDatabaseOPManager.GDB', 'SYSDBA', 'masterkey');

    $stmt = 'SELECT count(*) FROM OP';
    $result = ibase_query($dbh, $stmt);
    
    $row = ibase_fetch_assoc($result);
    $count = $row["COUNT"];
    //echo $count . "<br>";

    if( $count >0 ) {
        $total_pages = ceil($count/$limit);
    } else {
        $total_pages = 0;
    }
    if ($page > $total_pages) $page=$total_pages;
    $start = $limit*$page - $limit; // do not put $limit*($page - 1)
    //$start = 1;
    $SQL = "SELECT FIRST $limit SKIP $start LFDNR, KATEGORIE, ERSTDATUM, STICHWORT, ERSTELLER, BEARBEITER, STATUS FROM OP ORDER BY $sidx $sord";
    //echo $start . "-" . $limit . "<br>";
    //echo $SQL . "<br>";
    $result = ibase_query($dbh, $SQL);

    $responce->page = $page;
    $responce->total = $total_pages;
    $responce->records = $count;
    $i=0;
    while($row = ibase_fetch_assoc($result)) {
        $responce->rows[$i]['id']=$row[lfdnr];
        $responce->rows[$i]['cell']=array($row["LFDNR"],$row["KATEGORIE"],$row["ERSTDATUM"],$row["STICHWORT"],$row["ERSTELLER"],$row["BEARBEITER"],$row["STATUS"]);
        $i++;
    }
           
    echo json_encode($responce);
    
    ibase_close($dbh);   
?>

if i now try to select second or the third or .... for any time the first row was selected and deselected.

in the example on:

http://trirand.com/blog/jqgrid/jqgrid.html

it is possible to select any row and it is possible to search a record.
In my Grid i cant search for a record. After i click on search nothing is happend.

have anyone a idea what can i do?

15/01/2011
09:15
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

You do not have the right id

Replace

while($row = ibase_fetch_assoc($result)) {
        $responce->rows[$i]['id']=$row[lfdnr];
        $responce->rows[$i]

        ..............................

    }

With

while($row = ibase_fetch_assoc($result)) {
        $responce->rows[$i]['id']=$row["LFDNR"];
        $responce->rows[$i]

        ..............................

    }

Enjoy

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

15/01/2011
19:11
Avatar
AverageGuy
Atlanta, GA
Member
Members
Forum Posts: 3
Member Since:
15/01/2011
sp_UserOfflineSmall Offline

I don't think that was the answer to the question in the title.  I'm having the same problem.  I'm printing the row ID via

    onSelectRow: function(rowId, stat){
      console.log("Row id "+rowId+" Status "+stat);
   },

And no matter what row I click on, every other click results in the rowId showing up as 1.  At the same time row 1 background goes from normal to yellow and back.

Thanks,

Jim.

15/01/2011
19:17
Avatar
AverageGuy
Atlanta, GA
Member
Members
Forum Posts: 3
Member Since:
15/01/2011
sp_UserOfflineSmall Offline

Note: in my case I'm dynamically generating the grid via

        $("#list").addRowData(1,myRow);
if that makes any difference.

Jim.

15/01/2011
21:02
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Yes ther is a diffrence I will say big difference

$("#list").addRowData(1,myRow);

This will add data in the grid with rows with same ID = 1.

In order to make correct selection please generate uniquie ID for every row

Kind Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
46 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information