1

I have a jqGrid where i have a column with delete hyperlinks for each row, i just cant manke hyperlink to make an action like onclick=\"jQuery('#list').deleteRow('" + cl + "'); when i used simple button

{ name: 'act', index: 'act', width: 100, align: 'center', sortable: false}],
gridComplete: function () {
    var gr = jQuery('#list'); gr.setGridHeight("auto", true);

    var ids = jQuery("#list").jqGrid('getDataIDs');
    for (var i = 0; i < ids.length; i++) {
        var cl = ids[i];
       be = "<a href style='height:25px;width:120px;' type='button' title='Slet' onclick=\"jQuery('#list').jqGrid('delGridRow','" + cl + "',{reloadAfterSubmit:false, url:'@Url.Action("deleteRow")'});\" >Slet</>";
        jQuery("#list").jqGrid('setRowData', ids[i], { act: be });
    }
}
Timsen
  • 4,066
  • 10
  • 59
  • 117

1 Answers1

0

It I understand you correct you should

  1. add some value to href attribute. For example href='#'.
  2. You should insert return false; at the end of the code of onclick function. It will prevent default <a> behavior.
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • if i remove a in front of href then it is just text which shows up, instead of link, return false worked to prevent hyperlink to run through. so now problem is that i need to call on click event, since nothing happends when i klik delete – Timsen Aug 25 '11 at 11:17
  • @Timsen: I wrote you to your previous answer about the `delGridRow` method. There are no `deleteRow` method in jqGrid. Is it *your* method which you wrote as jQuery plugin or you wanted do use some standard jqGrid methods like `delGridRow` or `delRowData`? – Oleg Aug 25 '11 at 11:25
  • @Timsen: The same as what? Is `deleteRow` the same as `delGridRow` or the same as `delRowData`? Where is the corresponding code? Do you tried my suggestions? Do you have the results which you need? If the problem are still not solved you should post your current code, describe the expected behavior and the behavior which you currently have. – Oleg Aug 25 '11 at 11:38
  • Okay, deleteRow is an acition inside of my controller class which is called when button is clicked. Yes it is the same code. where u helped me with delete button, but now i decided that an link instead of button looks more stylish for my solution. I have tryed the code. It stoppes a href to complete action, so i get a chance to see delete Window where i can select if i want to delete or cansel. But i cant get past that windows, since nothing happend if i press delete. Onclick event does not get fired. – Timsen Aug 25 '11 at 12:01
  • Sorry my fold, as i can see code wasnt copy pased properly. Ive update the code with properly copy paste – Timsen Aug 25 '11 at 12:05
  • I got it to work now, it was some small mistakes which i keep doing. code should look like this: be = "Slet >"; – Timsen Aug 25 '11 at 12:17