Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to correctly associate double click with the Edit?
Message
 
 
À
10/04/2013 04:05:51
Information générale
Forum:
Javascript
Catégorie:
JQuery
Divers
Thread ID:
01570547
Message ID:
01570623
Vues:
25
Can we go back? If you see here, I can bind dblclick on the grid itself. If I change it to this:
$("#flexClients").flexigrid({
   url: '/Client/Client/',
   dataType: 'json',
   colModel: [
   { display: 'Client Id', name: 'Id', width: 100, sortable: true, align: 'center', hide: true },
   { display: 'Client #', name: 'Number', width: 100, sortable: true, align: 'center' },
   { display: 'Name', name: 'Name', width: 350, sortable: true, align: 'center' },
   { display: 'Contact 1', name: 'Contact1', width: 350, sortable: true, align: 'center' },
   ],
   buttons: [
   { name: 'Add', bclass: 'add', bimage: '../Content/Themes/FlexiGrid/Images/add.png', tooltip: 'Add new client', onpress: add },
   { name: 'Edit', bclass: 'edit', bimage: '../Content/Themes/FlexiGrid/Images/edit.png', tooltip: 'Edit selected client', onpress: edit },
   { name: 'Delete', bclass: 'delete', bimage: '../Content/Themes/FlexiGrid/Images/delete.png', tooltip: 'Delete selected client', onpress: del },
   { separator: true }
   ],
   searchitems: [
   { display: 'Client Name', name: 'Name' },
   { display: 'Contact 1', name: 'Contact1' }
   ],
   sortname: "Name",
   sortorder: "asc",
   usepager: true,
   title: 'Clients',
   useRp: true,
   rp: 15,
   rpOptions: [5, 10, 15, 20, 25, 40],
   showTableToggleBtn: true,
   width: 900,

   onSubmit: addFormData,
   //onDoubleClick: edit('Edit', this),
   //onSuccess: bindDblClick,
   addTitleToCell: true,
   hideOnSubmit: false,
   height: 'auto',
   singleSelect: true
});

//This function adds parameters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit			
function addFormData() {

   //passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
   var dt = $("#add-edit-form").serializeArray();
   dt = dt.concat($('#frmClientsSearch').serializeArray());

   $("#flexClients").flexOptions({ params: dt });
  
   return true;
}

//function bindDblClick() {
//   $('#flexClients tr').dblclick(function () {
//      alert('Double Click');
//      edit('Edit');
//   });
//}

$('#flexClients tr').dblclick(function () {
   alert('dblclick');
   edit();
});
then it's never get called at all when I double click on the row. So, adding tr here makes it not work.



>>Hi everybody,
>>
>>I have the following script
>>
>>
>>function edit(com, grid) {
>>   $('.trSelected', grid).each(function () {
>>
>>      var id = $(this).attr('id');
>>      id = id.substring(id.lastIndexOf('row') + 3);
>>      currentId = id;
>>      $('#fntype').val('Edit');
>>      var ClientName;
>>      ClientName = $('.trSelected td:eq(2)').text();
>>      var url = '/Client/Edit/' + id;
>>
>>      $.get(url, function (html) {
>>         $($dlg).html(html);
>>      });
>>
>>      RunModalDialog("Edit Client: " + ClientName);
>>
>>   });
>>}
>>
>>which is invoked this way:
>>
>>
>>   buttons: [
>>   { name: 'Add', bclass: 'add', bimage: '../Content/Themes/FlexiGrid/Images/add.png', tooltip: 'Add new client', onpress: add },
>>   { name: 'Edit', bclass: 'edit', bimage: '../Content/Themes/FlexiGrid/Images/edit.png', tooltip: 'Edit selected client', onpress: edit },
>>   { name: 'Delete', bclass: 'delete', bimage: '../Content/Themes/FlexiGrid/Images/delete.png', tooltip: 'Delete selected client', onpress: del },
>>   { separator: true }
>>   ],
>>
>>
>>and I also want to be able to double click on the row and invoke the same action.
>>
>>So, I tried (I am using latest jquery):
>>
>>
>>$('#flexClients').dblclick(function () {
>>   edit();
>>});
>>
>>but nothing happens.
>>
>>I know that the code itself attaches the handle correctly to dblclick (if I change the edit to alert, it fires).
>>
>>So, what I am doing wrong here and how should I adjust the above?
>>
>>Thanks a lot in advance.
>
>So the function gets called. What do you mean by 'nothing happens' ? Debug/Single step it.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform