-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal - Get temporary rowData while editing #1054
Comments
Hello Udi, Thank you for the recommendation - much appreciate all your efforts regarding jqGrid . To the request. I do not think that we need to add some additional code for what you need. ================================================================================= When the form is constructed we set the following rules:
<form ....>
<table>
<tr id='tr_myfield'>
<td> Caption</td> <td>edited element named, in colModel, as "myfield"</td>
</tr> ...
</table>
</form>
This allow us to easily show or hide some table rows depending on conditions using beforeShowForm event ================================================================================== Having this you can get easy any current value from the form like: $("#CustomerID").val(); or better if the grid has id grid $("#CustomerID", "#FrmGrid_grid").val(); In case you have different input types like checkbox, radio and etc you can simply var field_type = $("#CustomerID", "#FrmGrid_grid")[0].type and do appropriate o get the right value Similar to this there is description for cell edit and inline edit. Hope this will solve your problem Best Regards, |
or another easy current form value get (except maybe for some complex custom elements) If the jqGrid has id = grid var formid = "#"+"FrmGrid_grid",
fields = $(formid).serializeArray(),
griddata = {};
$.each(fields, function(i, field){
griddata[field.name] = field.value;
}); or using this thread you can add your own function: /*!
* jQuery serializeObject - v0.2 - 1/20/2010
* http://benalman.com/projects/jquery-misc-plugins/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Whereas .serializeArray() serializes a form into an array, .serializeObject()
// serializes a form into an (arguably more useful) object.
(function($,undefined){
'$:nomunge'; // Used by YUI compressor.
$.fn.serializeObject = function(){
var obj = {};
$.each( this.serializeArray(), function(i,o){
var n = o.name,
v = o.value;
obj[n] = obj[n] === undefined ? v
: $.isArray( obj[n] ) ? obj[n].concat( v )
: [ obj[n], v ];
});
return obj;
};
})(jQuery); Usage var current_form_data = $( "#"+"FrmGrid_grid").serializeObject(); |
Hi Tony, Well, if I look at your code for constructing "postdata", indeed this is what I see. Generally speaking, I would need to copy everything you have there, like: Getting simple values (input), getting values from standard type fields (select, buttons, etc.), getting values from custom fields, and eventually unformatting. You have done all of this very well, so I was just hoping I would have a way of using your code. This way, if ever you add more standard types, or any additional functionality, it would automatically be supported and available to me. But I understand it if you don't see potential for other people using this feature. Thank you for creating and maintaining jqGrid all these years. |
Hi Tony,
I would like to propose one new feature, based on a situation I'm facing now.
When you define a cusom-type column which has "choices" defined (like: INPUT with DATALIST in my case), sometimes you want to make the list of choices "dynamic". What I mean is, when the field gets focus, the list of choices should be created based on the value of other fields in the row.
The problem is that currently, the "rowData" object which is passed to the custom element creation function, does not reflect any changes which have already been done in the edit form. The values are only the "official" ones, before the planned changes. This way I cannot really see the changes which have not yet been saved.
Getting the field values from the edit form is slightly complicated. You need to consider different types, including custom types. I see that you are doing this in your code (when creating the postdata), but this code is not available for me to call and use. I was wondering if there's any way you could make this service available to users, so that I could call it and get the CURRENT data of the edit form. BTW, I guess the same applies for inline editing.
Thanks,
Udi
The text was updated successfully, but these errors were encountered: