EasyUI Forum
April 29, 2024, 09:24:57 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Get selected row index in datagrid  (Read 41008 times)
pacific202
Newbie
*
Posts: 35


View Profile
« on: October 12, 2011, 10:49:26 AM »

I am trying to update a datagrid using JavaScript, and see that the way to do this is using the updateRow method of the datagrid, which takes two arguments:

Quote
index: the row index to be updated.
row: the new row data.

Is there an easier way to get the selected index in the datagrid?  The only way I can see to do this is by getting the row data using getSelected then passing that data back in to a getRowIndex function.

Is there an example somewhere of how to use updateRow?  This is a complex form and I can't simply use CRUD to update the underlying table.
Logged
pacific202
Newbie
*
Posts: 35


View Profile
« Reply #1 on: October 12, 2011, 10:53:51 AM »

Apologies for the misinformation in the above post.  I have updateRow working, but it only takes one argument (of a complex object) and not two.

Here is my function, which updates a datagrid with two fields (Action and Parameters):

Code:
    function tasks_ChangeTask(){

        var selectedrow = $("#tasks-datagrid").datagrid("getSelected");
        var rowIndex = $("#tasks-datagrid").datagrid("getRowIndex", selectedrow);

        var rowData =   {
                            Action : $("#task-dialog-action").combobox("getValue"),
                            Parameters : $("#task-dialog-parameters").val()
                        };


        var param = {
                        index: rowIndex,
                        row: rowData
                    };
        
        $("#tasks-datagrid").datagrid("updateRow", param);
                    
        // close dialog
        $("#task-dialog").dialog("close");

    }

I still want to know how to get the selected row index easily in one step instead of two Smiley  I might have a datagrid with multiple rows that are exactly the same.
« Last Edit: October 12, 2011, 10:57:49 AM by pacific202 » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!