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
Trying to edit and save a cell with empty content
19/08/2009
01:22
Avatar
nisse
Member
Members
Forum Posts: 8
Member Since:
19/08/2009
sp_UserOfflineSmall Offline

Hello!

I have tried searching for this problem on this forum and inside the documentation, but have not found an answer for the following:

I am using jqgrid and the cellEdit feature. And it works quite well.

Now, I am wondering if the following is a default configuration or a bug:

Whenever I edit a cell that loads with a value and change it to nothing, it comes back to the previous value!

Example

Before: "test"
Change to: "test2"
Result after refresh: "test2"
That is, as expected

but the following is not what I want

Before: "test"
Change to: "" <-- nothing
Result after refresh: "test"
That is, not what I expected or want. I would like the cell to be empty!

I have tried the following:

-----------------------------------------
afterSaveCell:function(rowid,fieldname,value,iRow,iCol){
  if(value == '') {
  alert("empty!");
  jQuery("#list").setCell(rowid,fieldname,"&nbsp;");
   
  }
},
-----------------------------------------

I have also tried, undefined or null, but still does not work

And the alert works when I leave the cell empty, so it seems like it is intercepted correctly, but when I refresh the previous content of the cell comes back!!

How do I change that?

Thanks

nisse

19/08/2009
07:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

This is because we use setCell to store the value and if it is empty we do not set the new value.

Now maybe you should use beforeSaveCell to do this - something like

beforeSaveCell : function (rowid,colName, value, iRow,iCol) {

if (value == "" ) return "&nbsp;";

else return value;

}

Also some other note - if you save the value to the server check if you handle empty values.

Best 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.

19/08/2009
14:22
Avatar
nisse
Member
Members
Forum Posts: 8
Member Since:
19/08/2009
sp_UserOfflineSmall Offline

Thank you!

Your solution worked out fine. But I used:

if (value == “” ) return “ ”; 

instead of

if (value == “” ) return “&nbsp;”; 

Regards

Nisse

21/08/2009
03:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thanks I have fixed this bug in cellEdit in gitHub.

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.

30/06/2010
14:52
Avatar
gseroul
Member
Members
Forum Posts: 15
Member Since:
19/02/2010
sp_UserOfflineSmall Offline

Hi Tony,

Unfortunately this correction may introduced a bug : I have in my grid some empty cell (date). But when I edit a row and save the empty cell value is not '' but '&nbsp;' => then saving this as a date give me an error in my DB. If a field is null we should keep it at null no ?

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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