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

[Solved] Ajax Editing Master/DetailGrid

3 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 22 Oct 2010, 03:39 AM
Hi,

    I'm using Ajax grid editing in a master/detail grid.  So, my master grid use editing and my detail view also.  I have a special column bound to complex type (like employee.ascx, showing a dropdownlist) in you samples. Almost all works fine except that when I'm going in editing mode in my detail view (where my special column is), the value is not selected in dropdownlist.  The drop down is correctly feed, but the selection does not work.
Here is the code, my EditorTemplate is Role.ascx and my column bound is called Role
<script type="text/javascript">
  
    // find the dropdown first
    var $dropdown = $('#Role');
  
    $('<option/>', { text: '<none>', value: -1 })
          .prependTo($dropdown);
    // find the table row (tr) which is being edited
    var $tr = $dropdown.closest('tr:has(form)');
  
    // get the grid client object
    var grid = $tr.closest('.t-grid').data('tGrid');
  
    // get the data item bound to this table row
    var dataItem = grid.dataItem($tr);
    // set the value of the dropdown to select the proper item
    $dropdown.val(dataItem.Role ? dataItem.Role.RoleId : -1);
</script>

When I add alert to debug code, I see that my first alert is lauched, but not the second one and I don't understand why. 
<script type="text/javascript">
  
    alert($('#Role'));
  
    // find the dropdown first
    var $dropdown = $('#Role');
  
alert($('#Role'));
  
    $('<option/>', { text: '<none>', value: -1 })
          .prependTo($dropdown);
    // find the table row (tr) which is being edited
    var $tr = $dropdown.closest('tr:has(form)');
  
    // get the grid client object
    var grid = $tr.closest('.t-grid').data('tGrid');
  
    // get the data item bound to this table row
    var dataItem = grid.dataItem($tr);
    // set the value of the dropdown to select the proper item
    $dropdown.val(dataItem.Role ? dataItem.Role.RoleId : -1);
</script>

could you please help me?

Thank you

3 Answers, 1 is accepted

Sort by
0
Jigar
Top achievements
Rank 1
answered on 22 Oct 2010, 07:12 AM
Hi Steve,

Please have a look at these forum post

1. Grid Edit - Form Name
2. Currency Text Box - Sub Grid Edit Problem

these may solve your problem.

Regards,

Jigar.
0
Steve
Top achievements
Rank 1
answered on 22 Oct 2010, 11:41 AM
Hi,

    Thank you for your reply.  How can I change template guid to be unique?

Thank you
0
Steve
Top achievements
Rank 1
answered on 23 Oct 2010, 02:29 AM
Hi,

  I did many test and I succeed to find my subgrid fully qualified name (unique).  But it does not seems to help me.

I replaced:
var $dropdown = $('#Role');
by:
var $dropdown = $("#Roles_<#= UserId #>form").find("#Role");

and It does not work.  Both return same result.  I'm using the same script as presented in samples with Employees, but in a detailview grid. 
By the way, do you have a trick to debug those Ajax script?  It is very hard, because I don't know all the properties for each objects and the only one thing I'm able to do to debug is using alert().

Thank you
Steve
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Jigar
Top achievements
Rank 1
Steve
Top achievements
Rank 1
Share this question
or