jQWidgets Forums

Forum Replies Created

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts

  • KBhima
    Participant

    BTW am using angularjs and jqwidgets to develop this.

    Thanks


    KBhima
    Participant

    Thanks, the demo you provided helped me to fire the action on button click. However it did not provide me the complete solution.
    Following are the issues.
    1) When I click on the delete image, it deletes a row only for the first time I click the button , next time when I try to perform the same action, it just opens the confirm window and on clicking “OK”, it closes the confirm window but does not delete the row.
    2) Clicking the Edit image does not perform any action. It gives me following error: TypeError: data is undefined
    $scope.clientIdSettings.jqxInput(‘val’,data.ClientId);

    Following is the piece of code for both the EDIT and DELETE columns.

    { text: ”, datafield: ‘Edit’,
    createwidget: function (row, column, value, htmlElement) {
    var datarecord = value;
    var imgurl = ‘images/edit.png’;
    var img = ‘‘;
    var button = $(“<div style=’border:none;’>” + img + “<div class=’buttonValue’>” + value + “</div></div>”);
    $(htmlElement).append(button);
    button.jqxButton({ template: “success”, height: ‘100%’, width: ‘100%’ });
    button.click(function (event) {
    editrow = row;
    $scope.isDisabled = !$scope.isDisabled;
    var data = $scope.gridSettings.jqxGrid(‘getrowdata’, editrow);
    $scope.ClientIDInput.element.setAttribute(‘readonly’, ‘readonly’);
    $scope.clientIdSettings.jqxInput(‘val’,data.ClientId);
    $scope.clientNameSettings.jqxInput(‘val’,data.ClientName);
    });
    },
    initwidget: function (row, column, value, htmlElement) {
    var imgurl = ‘images/edit.png’;
    $(htmlElement).find(‘.buttonValue’)[0].innerHTML = value;
    $(htmlElement).find(‘img’)[0].src = imgurl;
    }
    },
    {
    text: ”, datafield: ‘delete’, width: 100,
    createwidget: function (row, column, value, htmlElement) {
    var datarecord = value;
    var imgurl = ‘images/remove.png’;
    var img = ‘‘;
    var button = $(“<div style=’border:none;’>” + img + “<div class=’buttonValue’>” + value + “</div></div>”);
    $(htmlElement).append(button);
    button.jqxButton({ template: “success”, height: ‘100%’, width: ‘100%’ });
    button.click(function (event) {
    $scope.jqxWindowSettings.jqxWindow(‘open’);
    $scope.Ok= function(row){
    deleterow =row;
    var selectedrowindex = $scope.gridSettings.jqxGrid(‘getselectedrowindex’);
    var rowscount = $scope.gridSettings.jqxGrid(‘getdatainformation’).rowscount;
    if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    var id = $scope.gridSettings.jqxGrid(‘getrowid’, selectedrowindex);
    var commit = $scope.gridSettings.jqxGrid(‘deleterow’, id);
    }
    $scope.jqxWindowSettings.apply(‘close’);
    }
    $scope.Cancel= function(){
    $scope.jqxWindowSettings.apply(‘close’);
    }

    });
    },
    initwidget: function (row, column, value, htmlElement) {
    var imgurl = ‘images/remove.png’;
    $(htmlElement).find(‘.buttonValue’)[0].innerHTML = value;
    $(htmlElement).find(‘img’)[0].src = imgurl;
    }
    }

    If you want to test it I have the complete code on the top of this page, you can just replace the above code in the EDIT and DELETE columns.

    Thanks


    KBhima
    Participant

    Hi Dimitar,

    Thanks for the response, Could you please provide me a sample in jqwidgets and angularjs as to how to do this dynamically.

    Thanks,


    KBhima
    Participant

    Am doing this for cancel, but it doesn’t work.

    $scope.cancel = function (row,event) {
    event.cancel =true;
    }

    It does not clear off anything.


    KBhima
    Participant

    Also how can I cancel if I don’t want to edit or add? That is when I click on a row to edit and then without saving wanted to cancel it.

    Thanks,

    in reply to: columnType Button in jqGrid columnType Button in jqGrid #85869

    KBhima
    Participant

    Never Mind, I was able to resolve this. I had to add cellsrenderer in columns.

    Thanks.

    in reply to: columnType Button in jqGrid columnType Button in jqGrid #85852

    KBhima
    Participant

    I couldn’t do it in JSEditor, here is my piece of code and yes am using jqxGrid.
    `<!DOCTYPE>
    <html ng-app=”demoApp”> <!– ng-app directive links angularjs app to html –>
    <head>
    <title>Grid directive for AngularJS</title>
    <link rel=”stylesheet” type=”text/css” href=”resources/css/jqx.base.css” />
    <link rel=”stylesheet” href=”resources/css/jqx.classic.css”
    type=”text/css” />
    <script type=”text/javascript” src=”resources/js/lib/angular.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jquery-3.0.0.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxcore.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxinput.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxdata.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxbuttons.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxcheckbox.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxgrid.js”></script>
    <script type=”text/javascript”
    src=”resources/js/lib/jqxgrid.selection.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxmenu.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxscrollbar.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxgrid.sort.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxgrid.edit.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxangular.js”></script>
    <script type=”text/javascript” src=”resources/js/lib/jqxgrid.columnsresize.js”></script>
    <script type=”text/javascript”>
    var demoApp = angular.module(“demoApp”, [“jqwidgets”]);

    //scopes are the objects that refer to the model and acts as a glue between controller and view.
    // controller maintains the application data and behavior using $scope object
    demoApp.controller(“demoController”, function ($scope) {

    // Grid data.
    $scope.client = [{
    ClientId: 1,
    ClientName: “ABC”
    }, {
    ClientId: 2,
    ClientName: “DEF”
    }, {
    ClientId: 3,
    ClientName: “XYZ”
    },
    {
    ClientId: 4,
    ClientName: “KLM”
    },{
    ClientId: 5,
    ClientName: “EFG”
    }];
    $scope.grid = {};
    // grid settings is used in jqx-settings attribute to call a method
    $scope.gridSettings =
    {
    altrows: false,
    sortable: true,
    //width: 500,
    //height: 200,
    disabled: false,
    columnsresize:true,
    ready: function()
    {
    source: datatype: “array”;
    dataFields:[
    {name: ‘ClientId’,type: ‘int’},
    {name: ‘ClientName’,type: ‘String’}
    ],
    $scope.grid.selectrow(0);
    },
    source: $scope.client,
    columns: [
    { text: ‘ClientId’, columntype: ‘textbox’, dataField: ‘ClientId’},
    { text: ‘ClientName’, columntype: ‘textbox’, dataField: ‘ClientName’ },
    { text: ‘Edit’, columntype: ‘button’, dataField: ‘Edit’ },
    { text: ‘Delete’, columntype: ‘button’, dataField: ‘Delete’ }
    ]

    };
    $scope.clientIdSettings = { width: 150, height: 30 };
    $scope.clientNameSettings = {
    created: function(args)
    {
    gridData= args.instance;
    },width: 150, height: 30};

    $scope.addSettings =
    {
    height: 30, width: 80

    };

    $scope.btnSettings = { height: 30, width: 80 };
    $scope.add = function () {
    //$(‘#input’).jqxInput(‘focus’);
    $scope.clientNameSettings.jqxInput(‘focus’);
    $scope.clientIdSettings.jqxInput(‘focus’);
    };

    $scope.edit = function()
    {
    var rowindex = $scope.gridSettings.jqxGrid(‘getselectedrowindex’);
    var data = $scope.gridSettings.jqxGrid(‘getrowdata’, rowindex);
    $scope.clientIdSettings.jqxInput(‘val’,data.ClientId);
    $scope.clientNameSettings.jqxInput(‘val’,data.ClientName);
    };

    $scope.delete = function ()
    {
    var selectedrowindex = $scope.gridSettings.jqxGrid(‘getselectedrowindex’);
    var rowscount = $scope.gridSettings.jqxGrid(‘getdatainformation’).rowscount;
    if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    var id = $scope.gridSettings.jqxGrid(‘getrowid’, selectedrowindex);
    var commit = $scope.gridSettings.jqxGrid(‘deleterow’, id);
    }
    };

    $scope.cancel = function (event) {
    event.cancel =true;
    };

    $scope.save = function()
    {
    var data = {
    ClientId: $scope.clientIdSettings.jqxInput(‘val’),
    ClientName: $scope.clientNameSettings.jqxInput(‘val’)
    };
    $scope.gridSettings.jqxGrid(‘addrow’, null, data);
    $scope.clientIdSettings.jqxInput(‘val’, ”);
    $scope.clientNameSettings.jqxInput(‘val’, ”);

    };

    });

    </script>
    </head>
    <body ng-controller=”demoController”>
    <div>
    <jqx-button jqx-settings=”btnSettings” jqx-create=”btnSettings” jqx-on-click=”add()”>New</jqx-button>

    <jqx-button jqx-settings=”btnSettings” jqx-create=”btnSettings” jqx-on-click=”edit()”>Edit</jqx-button>

    <jqx-button jqx-settings=”btnSettings” jqx-create=”btnSettings” jqx-on-click=”delete()”>Delete</jqx-button>
    </div>
    <br>

    <div >
    <jqx-grid jqx-instance=”grid” jqx-settings=”gridSettings”></jqx-grid>
    </div><br>

    <div><p>ClientID:
    <jqx-input jqx-settings=”clientIdSettings” jqx-create=”clientIdSettings”></jqx-input></p>
    <p>Client Name:<jqx-input jqx-settings=”clientNameSettings” jqx-create=”clientNameSettings”></jqx-input></p>
    </div><br>

    <div>
    <jqx-button jqx-settings=”btnSettings” jqx-create=”btnSettings” jqx-on-click=”save()”>Save</jqx-button>
    <jqx-button jqx-settings=”btnSettings” jqx-create=”btnSettings” jqx-on-click=”cancel()” style=”margin-left: 5px;”>Cancel</jqx-button>
    </div>

    </body>
    </html>


    KBhima
    Participant

    Hi Ivo,

    Thanks for the above responses, it was helpful. Am able to add the input box value to the grid now, however after adding the value I gave in the input box still sits there, if I want to add another value, I need to delete the previous value and then add it.
    Is there a way, the input box clears off after the data is added to the grid.


    KBhima
    Participant

    Thank you, will go through the link you shared.

    Thanks,
    KBhima


    KBhima
    Participant

    Thank you for the quick reply, this is what I wanted but I wanted it with angularJS and jqWidgets, I don’t see any angular JS in this.

    in reply to: jgxGrid with AngularJs jgxGrid with AngularJs #85712

    KBhima
    Participant

    Thanks

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