Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
how to send non-editable values to the server side in jqgrid?
28/05/2013
22:43
Avatar
jstuardo
Member
Members
Forum Posts: 9
Member Since:
28/05/2013
sp_UserOfflineSmall Offline

Hello.. I am new to this forum. I have downloaded jqgrid to retrieve some data from a SQL Server  table and I have some troubles:

I have a simple grid that has 4 columns coming from the database: ID, Name, CreationDate, ModificationDate. All of those fields are shown, but only Name is editable. The ID and the dates are shown as plain text.

The problem I have is when a record is modified. Only Name field is passed to the server side. The CreationDate is sent as the default value as 01/01/0001 and not the value that currently has.

This is my script:


<script type="text/javascript">
$(function () {
    $("#departamentos").jqGrid({
        url: "@Url.Action("List")",
        datatype: "json",
        mtype: "GET",
        colNames: ["@Html.DisplayNameFor(model => model.dep_id)",
                   "@Html.DisplayNameFor(model => model.dep_nombre)",
                   "@Html.DisplayNameFor(model => model.dep_creado_el)",
                   "@Html.DisplayNameFor(model => model.dep_modificado_el)",
                   " "],
        colModel: [
            { name: "dep_id", index: "dep_id", key : true, sortable:false, editable:false, editoptions:{readonly:true,size:10}, width: 90 },
            { name: "dep_nombre", index: "dep_nombre", editable:true, width: 250 },
            { name: "dep_creado_el", index: "dep_creado_el", width: 100, align: "center", formatter: "date" },
            { name: "dep_modificado_el", index: "dep_modificado_el", width: 100, align: "center", formatter: "date" },
            { name: 'acciones', width: 58, fixed: true, sortable: false, resize: false, formatter: 'actions', formatoptions: { keys: true } }
        ],
        jsonReader: {
            repeatitems: false
        },
        pager: "#pager",
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: "dep_nombre",
        sortorder: "asc",
        viewrecords: true,
        gridview: true,
        autoencode: true,
        multiselect: true,
        caption: "Departamentos",
        editurl: "@Url.Action("AjaxEdit")",
    });

$("#departamentos").jqGrid('navGrid', '#pager', { edit: true, add: true, del: true });

    $.jgrid.edit.addCaption = "Agregar Departamento";
    $.jgrid.edit.editCaption = "Modificar Departamento";
    $.jgrid.edit.saveData = "¡El departamento fue modificado! ¿Almacena los cambios?";

    $.jgrid.formatter.date.newformat = 'd-m-Y H:i';

});
</script>


Other problem is that, even when where is 11 records returned and only the first 10 are displayed, grid says that there is only 1 page.

Any help will be greatly appreciated

Thanks
Jaime

30/05/2013
19:12
Avatar
jstuardo
Member
Members
Forum Posts: 9
Member Since:
28/05/2013
sp_UserOfflineSmall Offline

I have solved it by retrieving the data again from database and setting the editable data. If there is a better solution, please advice.

Jaime

31/05/2013
00:42
Avatar
trendready
Annandale, VA
Member
Members
Forum Posts: 5
Member Since:
29/05/2013
sp_UserOfflineSmall Offline

set editrules:{edithiddend:true} to hide it from the edit form but you can still access it using posdata[column_name]l                                     

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
36 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information