0

I am looking for the examples for jqgrid with salesforce lightning. How to inject URL into jqgrid javascript??

so far i have managed to pull data from salesforce apex component but for supporting inline-edit i need to use URL that will call apex component's method with @RemoteAction

$(document).ready(function () {
    console.log(">>>1");
    //--
    action.setCallback(this, function(a) {
        if (a.getState() === "SUCCESS") {
            result = a.getReturnValue();
            console.log(result);
            //---=
            var editActionOptions = {
                keys: true,
                url:null,
                oneditfunc: function (rowid) {
                    console.log("row with rowid=" + rowid + " is editing.");
                },
                aftersavefunc: function (rowid, response, options) {
                    console.log("row with rowid=" + rowid + " is successfuly modified.");
                }
            };
            //-------------------------------------------------------------------------------------------------------
            $("#jqGrid").jqGrid({
                editurl: 'clientArray',
                datatype: "local",
                data:result,
                colModel: [
                    {
                        label: "Edit Actions",
                        name: "actions",
                        width: 100,
                        formatter: "actions",
                        formatoptions: {
                            keys: true,
                            editOptions: {},
                            addOptions: {},
                            delOptions: {}
                        }       
                    },
                    {
                        labe: 'ID',
                        name: 'empid',
                        width: 75
                    },
                    {
                        label : 'Name',
                        name: 'Name',
                        width: 140,
                        editable: true // must set editable to true if you want to make the field editable
                    },
                    {
                        label: 'dob',
                        name: 'dob',
                        width: 100,
                        editable: true
                    },
                    {
                        label: 'dln',
                        name: 'dln',
                        width: 120,
                        editable: true
                    }
                ],
                sortname: 'empid',
                loadonce: true,
                onSelectRow: editRow,
                onSave:onSaveRow,
                editParams: editActionOptions,
                width: 780,
                height: 400,
                rowNum: 150,
                pager: "#jqGridPager"
            });               

            //------------------------------------------------------------------------------------------------------
        } else if (a.getState() === "ERROR") {
            $A.log("Errors", a.getError());
        }
    });

    $A.enqueueAction(action);
0

First of all Salesforce strongly recommends not to use third party libraries for building functionalities using aura components.

If you still want to pursue this option.

ltng:require tag to load the library from a static resource and use the afterscriptloaded attribute to call a helper function to bind jqgrid to your html dom

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_ltng_require.htm

    styles="{!$Resource.SLDSv1 + '/assets/styles/lightning-design-system-ltng.css'}"

    scripts="{!$Resource.jsLibraries + '/jsLibOne.js'}"

    afterScriptsLoaded="{!c.scriptsLoaded}" />

scriptsLoaded function will contain the code to bind jqgrid tables to dom.

  • sorry about confusion, i am aware of javascript static urls. I need to reference Component (Apex). – dev.sforce Jan 21 '17 at 3:53
  • can you clarify what you mean when you say you want to reference component – RedDevil Jan 21 '17 at 4:14
  • jqrid needs url to action on the server side which in case of salesforce it is apex component having method @RemoteAction – dev.sforce Jan 21 '17 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.