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
Example for CouchDB and jqgrid with inline editing, some advice needed
19/03/2013
17:52
Avatar
catshout
New Member
Members
Forum Posts: 1
Member Since:
19/03/2013
sp_UserOfflineSmall Offline

I'm currently looking for an example that allows inline editing on a CouchDB with jqgrid. The code below is working but it doesn't update the CouchDB data when pressed the 'S' button. I did some reseach but couldn't find anything helpful with regard to jqgrid and CouchDB.

Any hints are really appreciated.

Database documents:

http://localhost/couchdb/examp....._docs=true

{"total_rows":2,"offset":0,"rows":[
{"id":"43bce16e1dc49f9317b8921ff80013bf","key":"43bce16e1dc49f9317b8921ff80013bf","value":{"rev":"1-e95711a1b37a7b4dbf6d3661e9eec530"},"doc":{"_id":"43bce16e1dc49f9317b8921ff80013bf","_rev":"1-e95711a1b37a7b4dbf6d3661e9eec530","name":"Gerald","message":"Hello World!"}},
{"id":"43bce16e1dc49f9317b8921ff8001510","key":"43bce16e1dc49f9317b8921ff8001510","value":{"rev":"1-c7f45d42a23c4a93523dff9d2fc8ebfd"},"doc":{"_id":"43bce16e1dc49f9317b8921ff8001510","_rev":"1-c7f45d42a23c4a93523dff9d2fc8ebfd","name":"Sandra","message":"Hello World too!"}}
]}

HTML for testing purposes:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
</head>
<body>
<link rel="Stylesheet" type="text/css" href="css/smoothness/jquery-ui.custom.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/smoothness/ui.jqgrid.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="js/grid.locale-en.js"></script>
<script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>
<script>
$( document ).ready(function() {
    //setup the grid
    var lastsel;
    $("#myGrid").empty().jqGrid({
        datatype: 'json',
        ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
        ajaxRowOptions: { contentType: 'application/json; charset=utf-8', type: "PUT" },
        url:'/couchdb/example/_all_docs?&limit=100&include_docs=true',
        mtype: 'GET',
        colNames: ['', 'Id', 'Name', 'Message'],
        colModel: [{name:'act',index:'act', width:75,sortable:false},
                   { name: 'id', index: 'id', hidden: true, classes: 'id' },
                   { name: 'doc.name', index: 'name', width: 500, editable:true },
                   { name: 'doc.message', index: 'message', width: 200, editable:true }],
        pager: jQuery('#pager'),
        jsonReader: {
            repeatitems: false
        },
        width: 832,
        height: "100%",
        scrollOffset: 20,
        rowNum: 10,
        rowList: [10, 15, 20, 25],
        sortname: 'name',
        sortorder: "asc",
        viewrecords: true,
        hoverrows: false,
        caption: "",
        /*
        onSelectRow: function(id){
            if(id && id!==lastsel){
                jQuery('#myGrid').jqGrid('restoreRow',lastsel);
                jQuery('#myGrid').jqGrid('editRow',id,true); lastsel=id;
            }
        },
        */
        gridComplete: function(){
            var ids = jQuery("#myGrid").jqGrid('getDataIDs');
            for(var i=0;i < ids.length;i++){
                var cl = ids[i];
                be = "<input style='height:22px;width:20px;' type='button' value='E' onclick="jQuery('#myGrid').editRow('"+cl+"');" />";
                se = "<input style='height:22px;width:20px;' type='button' value='S' onclick="jQuery('#myGrid').jqGrid('saveRow', '"+cl+"', false, 'clientArray');" />";
                ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick="jQuery('#myGrid').restoreRow('"+cl+"');" />";
                jQuery("#myGrid").jqGrid('setRowData',ids[i],{act:be+se+ce});
            }
        },
        editurl: '/couchdb/example',
        //beforeSelectRow: function (rowid, e) { return false; } //this disables row being highlighted when clicked
    });
});
</script>
<table id="myGrid"><tr><td/></tr></table>
<div id="pager"></div>
</body>
</html>
Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
64 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