Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery django开发服务器挂起firefox和chrome_Jquery_Mysql_Django - Fatal编程技术网

Jquery django开发服务器挂起firefox和chrome

Jquery django开发服务器挂起firefox和chrome,jquery,mysql,django,Jquery,Mysql,Django,我正在windows 8.1 64位上使用django development server。我也在用Tastypie。 mysql的版本是:5.5(x86) 我面临的问题是各种查询随机挂起。我在客户端使用AJAX,但在使用django管理员时也会发生这种情况。我看到所有类似的问题都与chrome问题有关。但在Firefox上也会发生这种情况。 我的数据库是mysql。最近我安装了SSD驱动器,所以我所有的开发代码和数据库都在那个SSD上(我不认为这会有什么不同) 下面是Firebug中出现的几

我正在windows 8.1 64位上使用django development server。我也在用Tastypie。 mysql的版本是:5.5(x86)

我面临的问题是各种查询随机挂起。我在客户端使用AJAX,但在使用django管理员时也会发生这种情况。我看到所有类似的问题都与chrome问题有关。但在Firefox上也会发生这种情况。 我的数据库是mysql。最近我安装了SSD驱动器,所以我所有的开发代码和数据库都在那个SSD上(我不认为这会有什么不同)

下面是Firebug中出现的几个查询的示例。在这种情况下,第四个挂起(随机,有时是另一个)

获取id=1“>http://127.0.0.1:8000/api/v1/financialmodel/?user_id=1 200 OK 1.33s jquery…min.js 获取id=1“>http://127.0.0.1:8000/api/v1/strategy/?user_id=1 200 OK 1.35s jquery…min.js(第6行) 获取id=1“>http://127.0.0.1:8000/api/v1/currency/?user_id=1 200 OK 1.4s jquery…min.js(第6行) 下一个查询被卡住(但这是随机的,有时是另一个查询) 获取id=1“>http://127.0.0.1:8000/api/v1/account/?user_id=1 jquery….min.js(第6行) 获取id=1“>http://127.0.0.1:8000/api/v1/bankbranch/?user_id=1 200正常2.62s

我尝试使用以下命令运行服务器:

带--nothread(或不带)的运行服务器

没有改变任何事情

我尝试安装//github.com/ashcristopher/django-concurrent-server 认为这可能会有所帮助,但同样的事情仍然随机挂在各种查询上

如果使用APTANA IDE中的调试器暂停服务器,我会发现服务器位于:

SocketServer.py行155

有什么想法吗? 非常感谢

以下是jquery-2.0.3中Ajax代码中的一行

// Do send the request

// This may raise an exception which is actually

// handled in jQuery.ajax (so no try/catch here)

                xhr.send( options.hasContent && 
options.data || null );
            },

            abort: function() {

                if ( callback ) {

                    callback();

                }

            }

        };

    }

});
以下是加载ui树的函数:

function loadAccountsTree() {
    $.getJSON("/api/v1/account/?user__id=" + userid, function(json) {
        // Extracting the required JSON structure from the entire response
        var tree = json.objects[0];
        $("#accounts-tree").jstree({
            "sort" : function() {
            },
            "json_data" : {
                "data" : tree
            },
            "types" : {
                "max_children" : 1,
                "types" : {
                    // Account type
                    "default" : {
                        "valid_children" : "none"
                    },
                    "folder" : {
                        "valid_children" : ["default", "folder"]
                    }
                }
            },
            "hotkeys" : {
                "return" : function() {
                    var hovered = $('#accounts-tree .jstree-hovered');
                    if (hovered.length) {
                        $("#accounts-tree").jstree("deselect_all");
                        $("#accounts-tree").jstree("select_node", hovered);
                    }
                }
            },
            "ui" : {
                select_multiple_modifier : false
            },
            "contextmenu" : {
                // Select node when right-clicking
                "select_node" : true,
                items : {// Could be a function that should return an object like this one
                    "ccp" : false,
                    "create" : {
                        "separator_before" : false,
                        "separator_after" : true,
                        "label" : "Create",
                        "action" : false,
                        "submenu" : {
                            "create_file" : {
                                "seperator_before" : false,
                                "seperator_after" : false,
                                "label" : "Account",
                                action : function(obj) {
                                    this.create(obj, "last", {
                                        "attr" : {
                                            "rel" : "default"
                                        }
                                    });
                                }
                            },
                            "create_folder" : {
                                "seperator_before" : false,
                                "seperator_after" : false,
                                "label" : "Folder",
                                action : function(obj) {
                                    this.create(obj, "last", {
                                        "attr" : {
                                            "rel" : "folder"
                                        }
                                    });
                                }
                            } // End of "create_folder" contextmenu function
                        }
                    }
                }
            },
            "plugins" : ["themes", "json_data", "ui", "hotkeys", "crrm", "dnd", "contextmenu", "types"]
        }).bind("before.jstree", function(e, data) {
            if (data.func === "remove") {
                var nodes = data.inst._get_node(null, true);
                for (var i = 0; i < nodes.length; i++) {
                    var node = nodes[i];
                    var nodeName = $(node).find('> a').text().substring(1);
                    if ($(node).find('> ul').length) {
                        alert('You need to delete all folders and accounts inside ' + nodeName + ' before deleting it.');
                        e.stopImmediatePropagation();
                        return false;
                    } else if (!confirm("Are you sure you want to delete " + nodeName + " ?")) {
                        e.stopImmediatePropagation();
                        return false;
                    }
                }
            }
        }).bind("loaded.jstree", function(event, data) {
            // Selecting top account
            data.inst.select_node('> ul > li:first');
            // Loading all assets for top account
            loadAccountAssets($("#accounts-tree > ul:first > li:first").attr("id"));
            loadCommissions($("#accounts-tree > ul:first > li:first").attr("id"));
        }).bind("create.jstree", function(e, data) {
            var newNode = data.rslt.obj;
            var verified = true;
            $(newNode).siblings().each(function(idx, listItem) {
                var siblingNode = $(listItem);
                if (newNode.attr("rel") !== siblingNode.attr("rel")) {
                    verified = false;
                    return false;
                }
            });
            var isFolder;
            if (data.rslt.obj.attr("rel") == 'default') {
                isFolder = 'false';
            } else {
                isFolder = 'true';
            }
            if (verified) {
                $.ajax({
                    type : 'POST',
                    // make sure you respect the same origin policy with this url:
                    // http://en.wikipedia.org/wiki/Same_origin_policy
                    url : '/api/v1/account/',
                    data : JSON.stringify({
                        'folder' : isFolder,
                        'user' : '/api/v1/user/' + userid + '/',
                        'parent' : '/api/v1/account/' + data.rslt.parent.attr("id") + '/',
                        'name' : data.rslt.name,
                        'type' : data.rslt.obj.attr("rel")
                    }),
                    contentType : "application/json",
                    dataType : 'json',
                    processData : false,
                    success : function(r) {
                        data.rslt.obj.attr("id", r.id);
                    },
                    error : function(xhr, textStatus, error) {
                        loadAccountsTree();
                        logErrors(xhr, textStatus, error);
                    }
                });
            } else {
                alert("Folders can contain either folders or accounts, not both at a time.");
                $(newNode).prev().addClass("jstree-last");
                $(newNode).remove();
            }
        }).bind("rename.jstree", function(e, data) {
            $.ajax({
                type : 'PATCH',
                url : '/api/v1/account/' + data.rslt.obj.attr("id") + '/',
                data : JSON.stringify({
                    "name" : data.rslt.new_name
                }),
                dataType : 'json',
                contentType : 'application/json',
                error : function(xhr, textStatus, error) {
                    loadAccountsTree();
                    logErrors(xhr, textStatus, error);
                }
            });
        }).bind("remove.jstree", function(e, data) {
            $.ajax({
                type : 'DELETE',
                url : '/api/v1/account/' + data.rslt.obj.attr("id") + '/'
            });
        }).bind("select_node.jstree", function(event, data) {
            var currentNode = data.rslt.obj;
            var ui_currency = ($('#usd').hasClass('active')) ? 'usd' : 'ils';
            var isFolder = currentNode.attr("rel") === "folder";
            if (isFolder) {
                $("#account-form").slideUp();
            } else {
                // The account is not a folder. Show account details and load its commissions.
                $("#account-form").slideDown();
                $("#account-name").attr("value", $(currentNode).text().substring(2));
                var bankId = $(currentNode).closest("li").data("bank_id");
                var accountBank = (bankId) ? bankId : "None";
                $("#bank").val(accountBank);
                $("#account-type").val($(currentNode).closest("li").data("account_type"));
                reloadAccountCommissions(currentNode.attr("id"));
            }
            reloadAccountAssets(isFolder, currentNode.attr("id"), ui_currency);
            var parents = currentNode.parents("li");
            var parentsList = currentNode.children("a").text().substring(1);
            parents.each(function(index) {
                parentsList = $(this).children("a").text().substring(1) + ' > ' + parentsList;
            });
            $("#account-title").text(currentNode.find("> a").text().substring(1) + " details");
            $("#account-breadcrumbs > p").text("Accounts: " + parentsList);
        }).bind("move_node.jstree", function(e, data) {
            data.rslt.o.each(function(i) {
                var valid = true;
                var currentNode = $(this);
                $(currentNode).siblings().each(function(idx, listItem) {
                    var siblingNode = $(listItem);
                    if (currentNode.attr("rel") !== siblingNode.attr("rel")) {
                        valid = false;
                        return false;
                    }
                });
                if (valid) {
                    $.ajax({
                        type : 'PATCH',
                        url : '/api/v1/account/' + currentNode.attr("id") + '/',
                        data : JSON.stringify({
                            "parent" : '/api/v1/account/' + data.rslt.np.attr("id") + '/'
                        }),
                        dataType : 'json',
                        contentType : 'application/json',
                        error : function(xhr, textStatus, error) {
                            loadAccountsTree();
                            logErrors(xhr, textStatus, error);
                        }
                    });
                } else {
                    $(data.rslt.op).append(currentNode);
                    $(currentNode).addClass("jstree-last");
                    alert("The parent folder can not contain folders and accounts at the same time.");
                }
            });
        });
    });
}
函数loadAccountsTree(){
$.getJSON(“/api/v1/account/?user\uu id=“+userid,function(json)){
//从整个响应中提取所需的JSON结构
var-tree=json.objects[0];
$(“#帐户树”).jstree({
“sort”:函数(){
},
“json_数据”:{
“数据”:树
},
“类型”:{
“max_儿童”:1,
“类型”:{
//帐户类型
“默认值”:{
“有效的_子项”:“无”
},
“文件夹”:{
“有效的子项”:[“默认”,“文件夹”]
}
}
},
“热键”:{
“return”:函数(){
var hovered=$(“#accounts tree.jstree hovered”);
如果(悬停。长度){
$(“#帐户树”).jstree(“全部取消选择”);
$(“#帐户树”).jstree(“选择#节点”,悬停);
}
}
},
“用户界面”:{
选择多个修改器:false
},
“上下文菜单”:{
//右键单击时选择节点
“选择_节点”:true,
items:{//可以是一个函数,它应该返回如下对象
"中共":假,,
“创建”:{
“之前的分隔符”:false,
“separator_after”:true,
“标签”:“创建”,
“行动”:虚假,
“子菜单”:{
“创建_文件”:{
“前分隔符”:false,
“separator_after”:false,
“标签”:“账户”,
行动:功能(obj){
创建(obj,“last”{
“属性”:{
“rel”:“默认值”
}
});
}
},
“创建文件夹”:{
“前分隔符”:false,
“separator_after”:false,
“标签”:“文件夹”,
行动:功能(obj){
创建(obj,“last”{
“属性”:{
“rel”:“文件夹”
}
});
}
}//结束“创建文件夹”上下文菜单功能
}
}
}
},
“插件”:[“主题”、“json_数据”、“ui”、“热键”、“crrm”、“dnd”、“上下文菜单”、“类型”]
}).bind(“before.jstree”,函数(e,数据){
如果(data.func==“删除”){
var节点=data.inst.\u get\u节点(null,true);
对于(var i=0;ia').text().substring(1);
if($(节点).find('>ul').length){
警报('在删除“+nodeName+”中的所有文件夹和帐户之前,需要先将其删除');
e、 停止即时复制();
返回false;
}如果(!confirm(“您确定要删除“+nodeName+”?”)则为else){
e、 停止即时复制();
返回false;
}
}
}
}).bind(“loaded.jstree”,函数(事件、数据){
//选择顶级客户
data.inst.select_节点('>ul>li:first
function loadAccountsTree() {
    $.getJSON("/api/v1/account/?user__id=" + userid, function(json) {
        // Extracting the required JSON structure from the entire response
        var tree = json.objects[0];
        $("#accounts-tree").jstree({
            "sort" : function() {
            },
            "json_data" : {
                "data" : tree
            },
            "types" : {
                "max_children" : 1,
                "types" : {
                    // Account type
                    "default" : {
                        "valid_children" : "none"
                    },
                    "folder" : {
                        "valid_children" : ["default", "folder"]
                    }
                }
            },
            "hotkeys" : {
                "return" : function() {
                    var hovered = $('#accounts-tree .jstree-hovered');
                    if (hovered.length) {
                        $("#accounts-tree").jstree("deselect_all");
                        $("#accounts-tree").jstree("select_node", hovered);
                    }
                }
            },
            "ui" : {
                select_multiple_modifier : false
            },
            "contextmenu" : {
                // Select node when right-clicking
                "select_node" : true,
                items : {// Could be a function that should return an object like this one
                    "ccp" : false,
                    "create" : {
                        "separator_before" : false,
                        "separator_after" : true,
                        "label" : "Create",
                        "action" : false,
                        "submenu" : {
                            "create_file" : {
                                "seperator_before" : false,
                                "seperator_after" : false,
                                "label" : "Account",
                                action : function(obj) {
                                    this.create(obj, "last", {
                                        "attr" : {
                                            "rel" : "default"
                                        }
                                    });
                                }
                            },
                            "create_folder" : {
                                "seperator_before" : false,
                                "seperator_after" : false,
                                "label" : "Folder",
                                action : function(obj) {
                                    this.create(obj, "last", {
                                        "attr" : {
                                            "rel" : "folder"
                                        }
                                    });
                                }
                            } // End of "create_folder" contextmenu function
                        }
                    }
                }
            },
            "plugins" : ["themes", "json_data", "ui", "hotkeys", "crrm", "dnd", "contextmenu", "types"]
        }).bind("before.jstree", function(e, data) {
            if (data.func === "remove") {
                var nodes = data.inst._get_node(null, true);
                for (var i = 0; i < nodes.length; i++) {
                    var node = nodes[i];
                    var nodeName = $(node).find('> a').text().substring(1);
                    if ($(node).find('> ul').length) {
                        alert('You need to delete all folders and accounts inside ' + nodeName + ' before deleting it.');
                        e.stopImmediatePropagation();
                        return false;
                    } else if (!confirm("Are you sure you want to delete " + nodeName + " ?")) {
                        e.stopImmediatePropagation();
                        return false;
                    }
                }
            }
        }).bind("loaded.jstree", function(event, data) {
            // Selecting top account
            data.inst.select_node('> ul > li:first');
            // Loading all assets for top account
            loadAccountAssets($("#accounts-tree > ul:first > li:first").attr("id"));
            loadCommissions($("#accounts-tree > ul:first > li:first").attr("id"));
        }).bind("create.jstree", function(e, data) {
            var newNode = data.rslt.obj;
            var verified = true;
            $(newNode).siblings().each(function(idx, listItem) {
                var siblingNode = $(listItem);
                if (newNode.attr("rel") !== siblingNode.attr("rel")) {
                    verified = false;
                    return false;
                }
            });
            var isFolder;
            if (data.rslt.obj.attr("rel") == 'default') {
                isFolder = 'false';
            } else {
                isFolder = 'true';
            }
            if (verified) {
                $.ajax({
                    type : 'POST',
                    // make sure you respect the same origin policy with this url:
                    // http://en.wikipedia.org/wiki/Same_origin_policy
                    url : '/api/v1/account/',
                    data : JSON.stringify({
                        'folder' : isFolder,
                        'user' : '/api/v1/user/' + userid + '/',
                        'parent' : '/api/v1/account/' + data.rslt.parent.attr("id") + '/',
                        'name' : data.rslt.name,
                        'type' : data.rslt.obj.attr("rel")
                    }),
                    contentType : "application/json",
                    dataType : 'json',
                    processData : false,
                    success : function(r) {
                        data.rslt.obj.attr("id", r.id);
                    },
                    error : function(xhr, textStatus, error) {
                        loadAccountsTree();
                        logErrors(xhr, textStatus, error);
                    }
                });
            } else {
                alert("Folders can contain either folders or accounts, not both at a time.");
                $(newNode).prev().addClass("jstree-last");
                $(newNode).remove();
            }
        }).bind("rename.jstree", function(e, data) {
            $.ajax({
                type : 'PATCH',
                url : '/api/v1/account/' + data.rslt.obj.attr("id") + '/',
                data : JSON.stringify({
                    "name" : data.rslt.new_name
                }),
                dataType : 'json',
                contentType : 'application/json',
                error : function(xhr, textStatus, error) {
                    loadAccountsTree();
                    logErrors(xhr, textStatus, error);
                }
            });
        }).bind("remove.jstree", function(e, data) {
            $.ajax({
                type : 'DELETE',
                url : '/api/v1/account/' + data.rslt.obj.attr("id") + '/'
            });
        }).bind("select_node.jstree", function(event, data) {
            var currentNode = data.rslt.obj;
            var ui_currency = ($('#usd').hasClass('active')) ? 'usd' : 'ils';
            var isFolder = currentNode.attr("rel") === "folder";
            if (isFolder) {
                $("#account-form").slideUp();
            } else {
                // The account is not a folder. Show account details and load its commissions.
                $("#account-form").slideDown();
                $("#account-name").attr("value", $(currentNode).text().substring(2));
                var bankId = $(currentNode).closest("li").data("bank_id");
                var accountBank = (bankId) ? bankId : "None";
                $("#bank").val(accountBank);
                $("#account-type").val($(currentNode).closest("li").data("account_type"));
                reloadAccountCommissions(currentNode.attr("id"));
            }
            reloadAccountAssets(isFolder, currentNode.attr("id"), ui_currency);
            var parents = currentNode.parents("li");
            var parentsList = currentNode.children("a").text().substring(1);
            parents.each(function(index) {
                parentsList = $(this).children("a").text().substring(1) + ' > ' + parentsList;
            });
            $("#account-title").text(currentNode.find("> a").text().substring(1) + " details");
            $("#account-breadcrumbs > p").text("Accounts: " + parentsList);
        }).bind("move_node.jstree", function(e, data) {
            data.rslt.o.each(function(i) {
                var valid = true;
                var currentNode = $(this);
                $(currentNode).siblings().each(function(idx, listItem) {
                    var siblingNode = $(listItem);
                    if (currentNode.attr("rel") !== siblingNode.attr("rel")) {
                        valid = false;
                        return false;
                    }
                });
                if (valid) {
                    $.ajax({
                        type : 'PATCH',
                        url : '/api/v1/account/' + currentNode.attr("id") + '/',
                        data : JSON.stringify({
                            "parent" : '/api/v1/account/' + data.rslt.np.attr("id") + '/'
                        }),
                        dataType : 'json',
                        contentType : 'application/json',
                        error : function(xhr, textStatus, error) {
                            loadAccountsTree();
                            logErrors(xhr, textStatus, error);
                        }
                    });
                } else {
                    $(data.rslt.op).append(currentNode);
                    $(currentNode).addClass("jstree-last");
                    alert("The parent folder can not contain folders and accounts at the same time.");
                }
            });
        });
    });
}
function loadAccountAssets(accountid) {
    $("#pager-account-assets").empty();
    var ui_currency = ($('#usd').hasClass('active')) ? 'usd' : 'ils';
    $("#jqgrid-account-assets").empty().jqGrid({
        url : '/api/v1/assetgrid/?user__id=' + userid + '&account__id__in=' + accountid + '&ui_currency_code=' + ui_currency,
        datatype : 'json',
        ajaxGridOptions : {
            contentType : "application/json"
        },
        jsonReader : {
            repeatitems : false,
            id : "id"
        },
        colNames : ['Account', 'Place', 'Subtype', 'Issuer', 'Price linkage', 'Interest type', 'Return net', 'Return gross', 'Maturity term', 'Maturity date', 'Symbol', 'Update', 'Update hint', 'Value', 'Currency', 'Units', 'Price', 'Description', 'FinancialModel'],
        // 'Issuer', 'Price linkage', 'Interest type', 'Return net', 'Return gross', 'Maturity term', 'Maturity date', 'Financialmodel',
        colModel : [{
            name : 'Account',
            edittype : 'select',
            editoptions : {
                dataUrl : '/api/v1/account/?user__id=' + userid + '&folder=false',
                buildSelect : function(data) {
                    var response = $.parseJSON(data);
                    var s = '<select>';
                    $.each(response.objects, function(index, account) {
                        s += '<option value="' + account.resource_uri + '">' + account.data + '</option>';
                    });
                    return s + "</select>";
                }
            },
            stype : 'select'
        }, buildHiddenColumn('Place', 'place', true, false, 'resource_uri', 'name'), buildHiddenColumn('Subtype', 'subtype', true, false, 'resource_uri', 'name'), buildHiddenColumn('Issuer', 'issuer', true, false, 'resource_uri', 'name'), {
            name : 'price_linkage',
            hidden : true,
            editable : true,
            edittype : 'select',
            editoptions : {
                value : 'F:Foreign Currency;M:Madad;I:ILS'
            },
            stype : 'select',
            editrules : {
                edithidden : true
            }
        }, {
            name : 'Interest',
            hidden : true,
            editable : true,
            edittype : 'select',
            editoptions : {
                value : 'F:Fix;C:Changing;O:Other'
            },
            stype : 'select',
            editrules : {
                edithidden : true
            }
        }, {
            name : 'Return Net',
            editable : true,
            editrules : {
                edithidden : true
            },
            hidden : true,
            editoptions : {
                dataInit : function(element) {
                    $(element).attr("readonly", true);
                }
            }
        }, {
            name : 'Return Gross',
            editable : true,
            editrules : {
                edithidden : true
            },
            hidden : true,
            editoptions : {
                dataInit : function(element) {
                    $(element).attr("readonly", "readonly");
                }
            }
        }, {
            name : 'Maturity',
            hidden : true,
            editable : true,
            edittype : 'select',
            editoptions : {
                value : 'S:Short;M:Medium;L:Long'
            },
            stype : 'select',
            editrules : {
                edithidden : true
            }
        }, {
            name : 'MaturityDate',
            hidden : true,
            editable : true,
            formatter : "date",
            editoptions : {
                dataInit : function(el) {
                    setTimeout(function() {
                        $(el).datepicker({
                            dateFormat : "yy-mm-dd"
                        });
                    }, 200);
                }
            },
            formoptions : {
                rowpos : 1,
                colpos : 2
            },
            formatoptions : {
                newformat : "Y-m-d"
            },
            editrules : {
                edithidden : true
            }
        }, symbolColumn, {
            name : 'Update',
            edittype : 'select',
            editoptions : {
                value : 'A:Automatic;M:Manual'
            },
            formoptions : {
                rowpos : 2,
                colpos : 2
            },
            stype : 'select',
        }, {
            name : 'UpdHint',
            formoptions : {
                rowpos : 3,
                colpos : 2
            }
        }, {
            name : 'Value',
            width : 70,
            editable : false
        }, currencyColumn, {
            name : 'Units',
            width : 70,
            formoptions : {
                rowpos : 4,
                colpos : 2
            },
            editoptions : {
                dataInit : function(elem) {
                    setTimeout(function() {
                        // It must be an integer
                        $(elem).numeric(false, function() {
                            alert("Integers only");
                            this.value = "";
                            this.focus();
                        });
                    }, 100);
                }
            }
        }, {
            name : 'Price',
            width : 70,
            formoptions : {
                rowpos : 5,
                colpos : 2
            },
            editoptions : {
                dataInit : function(elem) {
                    setTimeout(function() {
                        $(elem).numeric();
                    }, 100);
                }
            }
        }, {
            name : 'Description',
            formoptions : {
                rowpos : 6,
                colpos : 2
            },
            width : 200
        }, {
            name : 'FinancialModel',
            edittype : 'select',
            formoptions : {
                rowpos : 7,
                colpos : 2
            },
            editoptions : {
                dataUrl : '/api/v1/financialmodel/?user__id=' + userid,
                buildSelect : function(data) {
                    var response = $.parseJSON(data);
                    var s = '<select><option value="">None</option>';
                    $.each(response.objects, function(index, financialmodel) {
                        s += '<option value="' + financialmodel.resource_uri + '">' + financialmodel.data + '</option>';
                    });
                    return s + "</select>";
                }
            },
            stype : 'select'
        }],
        cmTemplate : {
            editable : true,
            width : 100
        },
        ondblClickRow : function() {
            var rowid = $("#jqgrid-account-assets").getGridParam('selrow');
            $('#jqgrid-account-assets').jqGrid('editRow', rowid, {
                keys : true,
                dataType : 'json',
                url : '/api/v1/assetgrid/' + encodeURIComponent(rowid) + '/',
                mtype : 'PATCH'
            });
        },
        serializeRowData : function(data) {
            return serializeAssetData(data);
        },
        ajaxRowOptions : {
            contentType : "application/json"
        },
        width : 835,
        shrinkToFit : false,
        gridview : true,
        height : "auto",
        autoencode : true,
        loadonce : true,
        rowNum : 10,
        rowList : [10, 20, 30],
        pager : "#pager-account-assets",
        viewrecords : true,
    }).jqGrid("navGrid", "#pager-account-assets", {
        search : false,
        refresh : false
    },
    // edit options
    {
        closeAfterEdit : true,
        mtype : "PUT",
        serializeEditData : function(data) {
            return serializeAssetData(data);
        },
        onclickSubmit : function(params, postdata) {
            params.url = '/api/v1/assetgrid/' + encodeURIComponent(postdata[this.id + "_id"]) + '/';
        },
        ajaxEditOptions : {
            contentType : "application/json",
            dataType : "json"
        },
        afterSubmit : function(response, postdata) {
            $('#jqgrid-account-assets').setGridParam({
                datatype : 'json'
            }).trigger('reloadGrid');
            return [true, '', false];
        },
        beforeShowForm : function(form) {
            centerDialog($("#editmodjqgrid-account-assets"));
        }
    },
    // add options
    {
        closeAfterAdd : true,
        mtype : "POST",
        serializeEditData : function(data) {
            return serializeAssetData(data);
        },
        onclickSubmit : function(params, postdata) {
            params.url = '/api/v1/assetgrid/';
        },
        afterSubmit : function(response, postdata) {
            $('#jqgrid-account-assets').setGridParam({
                datatype : 'json'
            }).trigger('reloadGrid');
            return [true, ''];
        },
        ajaxEditOptions : {
            contentType : "application/json",
            dataType : "json"
        },
        beforeShowForm : function(form) {
            centerDialog($("#editmodjqgrid-account-assets"));
        }
    },
    // delete options
    {
        // Delete parameters
        mtype : "DELETE",
        serializeDelData : function() {
            return "";
        },
        onclickSubmit : function(params, postdata) {
            params.url = '/api/v1/assetgrid/' + encodeURIComponent(postdata) + '/';
        },
        beforeShowForm : function(form) {
            centerDialog($("#delmodjqgrid-account-assets"));
        },
        afterSubmit : function(response, postdata) {
            $('#jqgrid-account-assets').setGridParam({
                datatype : 'json'
            }).trigger('reloadGrid');
            return [true, ''];
        }
    });
}