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
Blank cell values and the select formatter
17/08/2009
11:04
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

I have a function I wrote to add empty rows for my inline editing on my grids.  Since I have multiple grids that I use the function with I made it "generic" and it works great.  Here is the code:

function addEmptyRow(gridName){

// alert('Add a Row');
if(gridName) {
var rowcount = 0;
var ajaxURL;
var objName = gridName[0].id;
// Get the row count from the server
// This could be dangerous if lines have been deleted and added, messing up row counts
ajaxURL = '${.data_model.requestURI}?action=AjaxGetSubRecLastRow&recType='+objName+'&subid='+ $('#emplist').val();

        $.ajax({
          url: ajaxURL,
          async: false,
          cache: false,
          success: function(text){
                  rowcount = text;
                  rowcount++;
                }
 
        });
       
var rc = $(gridName).addRowData(rowcount,{' ':" "},"last"); // duplicate row numbers prevent editing/updating (FYI)

}

}

This will produce a row in the grid with each of the cells being empty AND the editoptions containing the select options will also display.

When I changed the colmodel in my grid to use the formatter:'select' option, the addEmptyRow function stopped returning the select values and the entire cell was missing from the row. I tracked it down to this code around line #283 in jquery.fmatter.js

} else if (!isEmpty(cellval)) {

Since I was passing empty values to the addRowData, the formatter wasn't returning the contents or the cell.  I removed the conditional on !isEmpty and ended up with this:

{ else  {
            if(!cellval)
                cellval = "";

Setting the cellval to ="" seemed to do the trick and so far I haven't seen any downside.  Is there a better way to handle adding an empty row that wouldn't require this "trick" to get the select lists to show?  I *think* this is a bug but it just could be one of those corner cases where the logic doesn't accomodate these values.

18/08/2009
11:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I think this have sence. Thanks. Fixed for the select.

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:
70 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