Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am facing a weird issue .
I gone through every possible way in google but no luck so far.possible help me if i am missing something ?

I done some comment stuff in my code below what i am looking exactly . To be short I just need a way to pass my prompt text which is stored in a Variable 'delreason' to CONTROLLER DELETE METHOD on my button click which is surely go to controller Delete method ?

My Code :
JavaScript
 delreason = '';
    $(document).ready(function () {
        var reason = $("#DropDown_Select").val()
        var oTable;


        $('#btnDeleteRow').click(function () {
            delreason = prompt("r u serious");
//When delete button is clicked i need to first gather the reason and pass to controller delete method i.e I ADOPTED QUERY STRING WAY as BELOW YOU CAN FIND sDeleteURL used like  query string so i can pass my Row-id asusual and additinally i can pass my prompt text entered .


            $(this).prop('disabled', true);

        });

            $('#myDataTable').dataTable().fnDestroy();

            oTable = $('#myDataTable').dataTable({
                "bProcessing": true,
                "bServerSide": true,
                "bAutoWidth": true,
                "bDestroy": true,
                "sAjaxSource": "AjaxHandler",
                "fnServerData": function (sSource, aoData, fnCallback) {

                    $('#DropDown_Select').change(function () {
                        alert($(this).val());
                        reason = $(this).val()
                        debugger;
                        //oTable.fnFilter($(this).val());
                        $.ajax({
                            "type": "GET",
                            "dataType": 'json',
                            "contentType": "application/json; charset=utf-8",
                            "url": sSource + "/" + reason,
                            "data": aoData,
                            "success": function (data) {

                                fnCallback(data);
                            }
                        });


                    });
                    $.ajax({
                        "type": "GET",
                        "dataType": 'json',
                        "contentType": "application/json; charset=utf-8",
                        "url": sSource + "/" + reason,
                        "data": aoData,
                        "success": function (data) {

                            fnCallback(data);
                        }
                    });
                },
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "aoColumns": [
                          {
                              "sName": "Lead_Id"
                                            ,
                              "bVisible": false,
                              "bSearchable": false,
                              "bSortable": false

                          },
                          {
                              "sName": "LeadName"
                              ,
                              "fnRender": function (oObj) {
                                  return '<a href=\"LeadIndividualDetail/' + oObj.aData[0] + '\">' + oObj.aData[1] + '</a>';
                              }
                          },
                           { "sName": "ContactName", "sClass": "hidden-xs" },
                           { "sName": "CompanyName" },
                           { "sName": "Product" }

                ]

            });


                oTable.makeEditable({

                    "sDeleteURL": "/Lead/DeleteData/?start=" + delreason, // query string way via URL .
                    sDeleteHttpMethod: "GET",
                    "event": "click",
                    "style": "inherit",
                    "width": ($('myDataTable').width() - 40) + "px",
                    "height": ($('myDataTable').height() + 20) + "px",
                    "aoColumns":
                    [
                        null,
                        null,
                        null,
                        null
                    ]
                });

      $("#myDataTable tbody tr").on('click', function (event) {
          debugger;
          alert("now");
          $("#myDataTable tbody tr").removeClass('row_selected');
          $(this).addClass('row_selected');
      });

    });


//I am getting row id at controller delete method but i am unable to get the prompt text in my controller where i tried to access like

var ReasonForDeletion = Request.QueryString["start"];

Am I missing something ? any better alternative is appreciated ?

I found some workaround but sadly its redirecting to other issue : If i want to get the PROMPT text at my controller i want to RELOAD MY **oTable.makeEditable({** CONTENT .. well but trying this simply i can't further move to select and delete any row after deleting firstRow ..

Any killer way to pass my prompt text using query string or whatever is appreciated to my controller Deletemethod on my click .

Regards
Posted
Updated 3-May-14 9:31am
v3
Comments
karthik Udhayakumar 3-May-14 15:33pm    
KF, kind request if you are updating the question make it clear grammatically and programmatically..:)
sunil gutta 3-May-14 15:36pm    
sorry i'm in a hurry at that time so there may be some errors . can you help with the solution ?
karthik Udhayakumar 3-May-14 15:35pm    
Sunil,
Whats the problem?request you to use improve widget option and elaborate clearly on which part you are really stuck up..code and requirement should be explained clearly ..otherwise others cannot help you out:)
sunil gutta 3-May-14 15:42pm    
With in my functionality i am doing like when deleting a row in data-table i want user to enter a reason (which will be prompt for now) and later things should happen usual . Here i dont know how to pass my reason text which i stored in variable delreason to CONTROLLER ?
sunil gutta 3-May-14 15:53pm    
code works fine apart from the prompt text as i am unable to pass from view to controller . possible suggest how to pass ? so i can work around the things . Looking into code makes things complex but what i need is much simpler than the code i given .sorry if it confused you .

1 solution

I have done it using query string . Which works as a charm .

Code looks like this :

JavaScript
$('#btnDeleteRow').click(function () 
            {
                var Del_Reason;
                $("#divid").dialog({
                    resizable: false,
                    height: 250,
                    width:300,
                    modal: true,
                    cache: false,
                    buttons:
                    {
                        "Ok": function () 
                        {
                            Del_Reason = $("#txtprompt").val()
                            
                            if (Del_Reason.length <= 0)
                            {
                                $('#lblerror').text("Please enter");
                            }
                            else
                            {
                                $.ajax({
                                    "type": "GET",
                                    "dataType": 'json',
                                    "contentType": "application/json; charset=utf-8",
                                    asy: false,
                                    "url": "/Lead/DeleteData/?id=" + Row_id + "&Del_Reason=" + Del_Reason + "&Status=" + status,
                                    "data": aoData,
                                    "success": function (data)
                                    {
                                         oTable.fnClearTable(0);
                                         oTable.fnDraw();
                                        //oTable.fnDeleteRow();
                                    }
                                });

                                $(this).dialog("close");
                             
                            }

                        },
                        Cancel: function ()
                        {
                            $(this).dialog("close");
                        }
                    }
                });

           
                });


Regards
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900