Search code examples
asp.net-mvc-3datatablesjeditabledatatable.select

JEditable using Select on MVC 3


I'm currently want to display a list of data using DataTables. And I want to be able to edit the record inline. I could execute those with no problem. The problem is, when I try to use drop down list(select) on one of the field for JEditable, that's when everything stuck to no where.

I would like to fetch the data from one of my table in MSSQL and dump it on data : "{ 'test' : 'test' }" for example. but I cant find a way to do that. My JS knowledge is not that good.

Is there any way I could execute this? With this question, I include my current codes: this is my initialization for Datatables and JEditable

$(document).ready(function () {
    $('#myItem').dataTable({
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": 'Items/AjaxDataProvider',
        "sPaginationType": "full_numbers",
        "aoColumns": [
                                { "sName": "ID",
                                    "bSearchable": false,
                                    "bSortable": false,
                                    "bVisible": false
                                },
                    { "sName": "NAME" , "sWidth" : "20%" },
                    { "sName": "UOM", "sWidth": "7%" },
                    { "sName": "REMARKS", "sWidth" : "8%"},
                                { "sName": "BARCODE", "sWidth": "8%" },
                                { "sName": "WITH SERIAL", "sWidth": "10%" },
                                { "sName": "MODEL" }
             ]
    }).makeEditable({
        sUpdateURL: "/Items/UpdateData",
        sAddURL: "/Items/AddData",
        sDeleteURL: "/Items/DeleteData",
        aoColumns: [
        {  },
        {   
            type: "select",
            onBlur: "submit",
            data: "{ ???? : ???? }"          
        },
        {  },
        {  },
        {  },
        {  },
        {  },
        {  },
        {  },
        {  },
        {  } ]
    });
});

I would like to insert into data area in makeEditable for second which is for UOM from this result:

var selectData = from a in db.Table select new[] { Convert.ToString(m.ID), Convert.ToString(m.Name) };

Anyone could give me a hand on solving this one?

Thanks a lot in advanced o/


Solution

  • I have finally manage to get the value for my selection list from SQL. The steps are written at my blog at Negative Zero