This is a migrated thread and some comments may be shown as answers.

Self Referencing Grid - Unable to edit child row

3 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
web
Top achievements
Rank 1
web asked on 29 Dec 2010, 09:33 PM
Hi, sorry if this is a basic question but I need some direction on how to call editItem() client-side on a child row in a hierarchical grid (which could have 3 or more levels).

I understand that the get_itemIndexHierarchical() returns a string representing the path and also how some recommend using the last part after the last underscore.  But I have had no luck figuring out how to use it and all my iterations of code end up either blowing up with id or object is null or it selects the parent.

Current iteration of my code:

function ElementRowDblClick(sender, eventArgs) {
        var grid = sender;
        var MasterTable = grid.get_masterTableView();
        var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
 
        debugger;
        $find("<%= rgData.MasterTableView.ClientID %>").editItem(row);
}

Can anyone help point me in the right direction? 

I have pondered using the string ("0:0_0:0_0") and parsing it to calculate a row index however it seems I would have to traverse child items or recursively search for an item to pass it to editItem()? I have set HierarchyLoadMode="Client" and GroupLoadMode="Client" although I'm not using groups anyway. And client settings are:

<ClientSettings  AllowExpandCollapse="true"  >
        <ClientEvents OnRowDblClick="ElementRowDblClick" />
            <Selecting AllowRowSelect="True" />
        </ClientSettings>

I have trawled many forum postings but can't seem to find anything similar to what I want to achieve, i.e. putting the row I double click into edit, via editItem(), and not just the parent row.

Any help very much appreciated.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Dec 2010, 10:43 AM
Hello,

Try the following code snippet to put the child row in edit mode.

ASPX:
<ClientSettings  AllowExpandCollapse="true"  >
    <ClientEvents OnRowDblClick="ElementRowDblClick" />
    <Selecting AllowRowSelect="True" />
</ClientSettings>

Java Script:
<script type="text/javascript">
    function ElementRowDblClick(sender, eventArgs) {
        editedRow = eventArgs.get_itemIndexHierarchical();
        $find("<%= rgData.MasterTableView.ClientID %>").editItem(editedRow);
   }
</script>

Thanks,
Princy.
0
web
Top achievements
Rank 1
answered on 30 Dec 2010, 09:19 PM
Thanks for the suggestion but I have tried that as well.  Here is a list of things that have not worked for me:

<script type="text/javascript" language='javascript'>
function ElementRowDblClick(sender, eventArgs) {
    editedRow = eventArgs.get_itemIndexHierarchical();
    $find("<%= rgData.MasterTableView.ClientID %>").editItem(editedRow);
</script>

Javascript Runtime Error = "Object Required"


<script type="text/javascript" language='javascript'>
function ElementRowDblClick(sender, eventArgs) {
    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
</script>

Javascript Runtime Error = "Object Required"

<script type="text/javascript" language='javascript'>
function ElementRowDblClick(sender, eventArgs) {
    var rowIndex = eventArgs.get_itemIndexHierarchical();
         
        //debugger;
        if (rowIndex.indexOf(':') != -1) {
            rowIndex = rowIndex.substr(rowIndex.lastIndexOf('_') + 1);
        }
        $find("<%= rgData.MasterTableView.ClientID %>").editItem(rowIndex);
</script>

Sets the top level parent row to edit instead of the row double clicked.

<script type="text/javascript" language='javascript'>
function ElementRowDblClick(sender, eventArgs) {
    var thisRow = masterTableView.get_rows()[eventArgs.get_itemIndexHierarchical()];
    $find("<%= rgData.MasterTableView.ClientID %>").editItem(thisRow);
}
</script>

I was playing around so this failed completely with object does not support this property or method ...

I wonder if it is something to do with it being a self-referencing hierarchy.
0
web
Top achievements
Rank 1
answered on 04 Jan 2011, 09:20 PM
Here is a workaround for anyone who experiences the same issue with self-referencing hierarchical:

<script type="text/javascript" language="javascript">
 
    function ElementRowDblClick(sender, eventArgs) {
        
        // get the row double clicked
        var thisRow = eventArgs.get_item();
         
        // explicitly set the id as it is not being set internally
        thisRow.id = thisRow.get_id();
 
        // edit this row
        sender.get_masterTableView().editItem(thisRow);
    }
    
 </script>

This has got me going successfully.
Tags
Grid
Asked by
web
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
web
Top achievements
Rank 1
Share this question
or