خرید بک لینک

Vote count: 0

I'm working in JqGrid with MVC 4.0 application. How to dynamically set the column names which comes from controller. I want to set the colModel and colnames dynamically. not with static values. kindly me on this.

 var grid = new JqGridObject()
            {
                Page1 = page,
                PageSize = 500,
                SortColumn = sidx,
                SortOrder = sord,
                Data = GetData("CRM-SALES"),
                ColumnAry = GetColumn("Input")
            };
             retu Json(grid, JsonRequestBehavior.AllowGet);
             //json1 = json.toJson(grid);

Here is my jqgrid i have tried by myself

         $.ajax({
        type: "POST",
        url: action,

        data: {},

        // contentType: "application/json;charset=utf-8",
        dataType: "json",
        //   processData: true,
        success: function (data, status, xhr) {
            alert('hi');
            var col;

            $.each(colData.ColumnAry, function () {

                alert(this['columame']);
                col.push(this["columame"]);
            });


            $("#myGrid").jqGrid({
                url: '@Url.Action("Search")',
                datatype: 'json',
                myType: 'POST',
                colNames: col,
                colModel: { name: col },

                jsonReader: {
                    root: 'Data',
                    id: 'id',
                    repeatitems: false
                },

                pager: "#myPager",
                width: 'auto',
                height: 'auto',
                rowNum: 100,
                rowList: [10, 25, 50, 100, 250, 500, 1000, 2000, 5000],
                loadonce: true,
                sortable: true,
                sortname: "OrderID",
                sortorder: "desc",
                viewrecords: true,
                gridview: true,
                autoencode: true,
                ignoreCase: true,
                afterInsertRow: function(rowId,data)
                {
                   // jQuery("#myGrid").setCell(rowId, 'status', data.cellvalue, { background: 'red' });

                },
                loadComplete: function (rowId,data)
                {
                    var ids = jQuery("#myGrid").jqGrid('getDataIDs');


                },

                //pager: $('#myPager'),
                // rowNum: 500,

                width: 1280, height: 500,
                //viewrecords: true,
                caption: 'Details'
            });

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 خرداد 1395 ساعت: 2:14

صفحه بندی