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
Getting the unique ID for a row when inline editing
31/12/2008
12:51
Avatar
pkinsman
Member
Members
Forum Posts: 7
Member Since:
31/12/2008
sp_UserOfflineSmall Offline

I have searched the forums and have not been able to find an answer to this question, even though I am sure I am not the first to encounter this issue.

I noticed that you have to set each field as "editable" in order to have jqGrid post the value back to the server.  So, I have the make the primary key editable in order to make inline editing work, so I know which record to update on the server side.

I was OK with this, but then they asked me to add a delete feature.  I have noticed that the value of editable text fields comes back looking something like "<input class="editable" name="ftevalue" id="1_ftevalue" style="width: 99%;" type="text">".  If you make the field non-editable, you get back the actual value of the field.

So, if I make the ID field non-editable, the delete feature works (because the value will come back properly), but now my inline editing is broken!

Please help!

31/12/2008
13:17
Avatar
geek
Member
Members
Forum Posts: 10
Member Since:
29/12/2008
sp_UserOfflineSmall Offline

When using inline editing you can add handlers for any of events listed in the documentation (Cell Editing -> Events) (http://www.secondpersonplural....../index.htm)

Nearly all of these events provide the following to your handler:

  • rowid - is the rowid (this is the unique row id you are referring to)
  • cellname is the name of the cell (name from colModel)
  • value - the value of the cell
  • iRow - the index of the row (do not mix with rowid)
  • iCol - the index of the column
  • I am doing exactly this in my own implementation.  I do not display the ID column at all.  I simply reference the rowid provided to tell me the ID corresponding to the data I am saving/deleting.

    Hope this helps!

    31/12/2008
    13:39
    Avatar
    pkinsman
    Member
    Members
    Forum Posts: 7
    Member Since:
    31/12/2008
    sp_UserOfflineSmall Offline

    Thanks so much for your quick reply!  I will give this a shot.Smile  

    05/01/2009
    09:57
    Avatar
    pkinsman
    Member
    Members
    Forum Posts: 7
    Member Since:
    31/12/2008
    sp_UserOfflineSmall Offline

    geek said:

    I am doing exactly this in my own implementation.  I do not display the ID column at all.  I simply reference the rowid provided to tell me the ID corresponding to the data I am saving/deleting.


    Hmmm actually I don't get it.  How are you using the rowid to get the real ID?  Maybe you can post an example?  Wink

    05/01/2009
    15:10
    Avatar
    geek
    Member
    Members
    Forum Posts: 10
    Member Since:
    29/12/2008
    sp_UserOfflineSmall Offline

    The rowID is the real ID.  When setting up your grid you specify what the ID is.  In my case, I am using an xmlReader which looks like this:

     xmlReader: {
     root: "DocumentElement",
            row: "Table1" ,
            page: "DocumentElement>currentpage",
            total: "DocumentElement>totalpages",
            records: "DocumentElement>totalrecords",
            repeatitems: false,
            id: "guidBranch"          
    }

    You can alternatively specify the ID by using the key property in your colModel definition like this:

    colModel: [
                {name:'guidBranch' ,index:'guidBranch', key=true},
    ]

    At this point, when any of the aforementioned events are fired (i.e. afterSaveCell)  the rowID passed in this even is your "real" ID which is presumably your primary key.

    Hopefully this helps, again 🙂

    06/01/2009
    09:27
    Avatar
    pkinsman
    Member
    Members
    Forum Posts: 7
    Member Since:
    31/12/2008
    sp_UserOfflineSmall Offline

    Thanks again.  I actually tried this a while ago but couldn't get it to work. Now that I see it's working for you I'll give it another shot!  

    08/01/2009
    08:04
    Avatar
    tony
    Sofia, Bulgaria
    Moderator
    Members

    Moderators
    Forum Posts: 7721
    Member Since:
    30/10/2007
    sp_UserOfflineSmall Offline

    Hello,

    I do not understand right what is used - inline editing or cell editing? Both are diffrent things.

    Regards

    Tony

    For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

    Forum Timezone: Europe/Sofia

    Most Users Ever Online: 715

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