jQuery UI Widgets Forums Grid Get row id and send it to my action C#

This topic contains 4 replies, has 2 voices, and was last updated by  ivailo 8 years, 2 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Get row id and send it to my action C# #82764

    anderson_tuy
    Participant

    Hey guys, sorry if this question has been asked before, i did not find any similar question.

    I have a grid and my data is coming from database. Everything is working fine. So i created a new column and i added some glypicons. Each row has the data and in the end the glyphicon representing my CRUD. Below you can see my code.

    columns: [
    { text: “Id”, datafield: “ID”, cellsalign: ‘center’, cellsformat: ‘d’, width: 50, renderer: columnsrenderer },
    { text: “Cliente”, datafield: “cliente”, cellsalign: ‘center’, width: 370, renderer: columnsrenderer },
    { text: “Grupo”, datafield: “grupo”, cellsalign: ‘center’, cellsformat: ‘N’, width: 80, renderer: columnsrenderer },
    { text: “Cota”, datafield: “cota”, cellsalign: ‘center’, cellsformat: ‘N’, width: 80, renderer: columnsrenderer },
    { text: “Contrato”, datafield: “contrato”, cellsalign: ‘center’, cellsformat: ‘N’, width: 100, renderer: columnsrenderer },
    { text: “Usuario”, datafield: “usuario”, cellsalign: ‘center’, width: 100, renderer: columnsrenderer },
    {
    text: “Data de Alteração”, datafield: “alteracao”, cellsalign: ‘center’, width: 170, renderer: columnsrenderer, cellsformat: ‘dd/MM/yyyy HH:mm:ss’, filtertype: “date”, createfilterwidget: function (column, columnElement, widget) {
    $(widget).jqxDateTimeInput({ formatString: ‘dd/MM/yyyy’ });
    }
    },
    {
    text: “Calculo Rateio”, width: 190, renderer: columnsrenderer,
    cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) {

    defaulthtml = ‘<span class=”glyphicon glyphicon-eye-open” title=”Ver”></span> <i class=”glyphicon glyphicon-pencil” title=”Editar”></i> <i class=”glyphicon glyphicon-trash” title=”Excluir” onclick=””></i>‘;
    return defaulthtml;

    }

    }
    ],

    Each row of my grid has an ID.
    So the @url.Action is suppose to call my action in my controller. My code is in C# and i am working with MVC. My CRUD is working too.

    My grid

    When a click in the plus sign above my grid it goes to my spreadsheet page. It´s like a calculator.

    My spreadsheet

    I associate this transaction to a client. So i return to the grid and the name is there with it´s respective ID.

    Grid_after

    The create(CRUD) works bacause it does not need an ID. But the glyphicons that go to my other actions Read, Edit and Delete does not, because i dont know how to get the ID of the selected row and send it to my action in Controller.
    The problem is: How to get the ID of the selected row and send it to my action ?? Does anyone know ??

    My code in the controller for example

    //GET: /CRUD/ EDITAR
    public ActionResult Edit(int? ID)

    {
    if (ID == null)
    {
    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }
    diluicao_normal _d = db.diluicao_normal.Find(ID);
    if (_d == null)
    {
    return HttpNotFound();
    }
    return View(_d);
    }

    //POST: /CRUD/ EDITAR
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Edit(diluicao_normal _d)
    {
    if (ModelState.IsValid)
    {
    db.Entry(_d).State = EntityState.Modified;
    db.SaveChanges();
    return RedirectToAction(“/Listar/Index/”);
    }
    return View(_d);
    }

    Thank you guys! Any doubt just ask. I will be around

    • This topic was modified 8 years, 3 months ago by  anderson_tuy.
    Get row id and send it to my action C# #82767

    ivailo
    Participant

    Hi anderson_tuy,

    Please, look at this demo with widget column. Probably it can be helpful for you.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com


    anderson_tuy
    Participant

    Thanks Ivailo

    I saw the demo and i have some questions.

    Even if my data is coming from the database it works with array???

    So is it possible to send row ID in Json to my action controller in C# ??

    A friend of mine that is Senior Programmer said is not possible to send data from Json to C#. I am afraid that after 1 week working on it i find out that is not possible.


    anderson_tuy
    Participant

    .

    • This reply was modified 8 years, 3 months ago by  anderson_tuy.

    ivailo
    Participant

    Hi anderson_tuy,

    Please, check our asp.net documentation section.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.