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
Add colmodel option: Addable
15/11/2011
15:42
Avatar
brecht
Member
Members
Forum Posts: 9
Member Since:
11/02/2010
sp_UserOfflineSmall Offline

Hi

I'de like to have an option 'Addable' or 'Insertable' on the colModel.
Why? Imagine this scenario:

I want a grid on a table with all crud operations. My table can have multiple columns which I don't want to be edited, like eg: primary key(s), incremental id, .. . However, I want some of those uneditable columns to be insertable in the add form.

I tackled this by following workaround in the navgrid add dialog properties:

  recreateForm: true,   beforeShowForm: function (formid) {                             // Add fields which are addable but not editable. jQgrid doesn't know a property 'Addable'.
    var extraAddable = jQuery("#GenericTableManager").jqGrid('getGridParam', 'colModel');

    for (var i = extraAddable.length -1; i > 0 ; i--) {
        if (extraAddable[i].addable) {
            $('<tr id="tr_' + extraAddable[i].name + '" class="FormData">' +
                '<td class="CaptionTD">' + extraAddable[i].name + '</td>' +
                '<td class="DataTD">' +
                    '<input id="' + extraAddable[i].name + '" class="FormElement ui-widget-content ui-corner-all" type="text" name="'
                        + extraAddable[i].name + '" role="textbox">' +
                '</td>' +
              '</tr>')
                .insertAfter($('.tinfo'));
        }
    }
}

Works just fine, but would be nice if this was a default option.

Sorry about the edits: pasting code is one hardcore business.

17/11/2011
14:20
Avatar
brecht
Member
Members
Forum Posts: 9
Member Since:
11/02/2010
sp_UserOfflineSmall Offline

Didn't like the implementation.

This is better:

recreateForm: true,
beforeInitData: function (formid) {                                      // Add fields which are addable but not editable. jQgrid doesn't know a property 'Addable'.
      colModelIterator(function(col) {
          if (col.addable) {
             grid.setColProp(col.name, { editable: true });
          }
      });
},
afterComplete: function (response, postdata, formid) {
// Remove editable option.
   colModelIterator(function (col) {
       if (col.addable) {
          grid.setColProp(col.name, { editable: false });
        }
    });
}

function colModelIterator(callback) {
    var colModel = grid.jqGrid('getGridParam', 'colModel');
    for (var index in colModel) { callback(colModel[index]); }
}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
50 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