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
Reload grid
12/10/2010
12:24
Avatar
penck
Member
Members
Forum Posts: 6
Member Since:
12/10/2010
sp_UserOfflineSmall Offline

Hi

I'm a beginner in jqgrid . when I tried to use it, I've met this problem :

 I set loadonce= true, and set datatype="local",  the grid is OK on the page .
and now I need to research the data from the server side and reload the grid ,
I tried some methods from internet , but doesn't work, or maybe I could not use 
"loadonce = true" at this time ?  

please help .... 

12/10/2010
13:34
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi

Look at this old answer. You should just reset the datatype to "local" before reloading of the grid.

Regards
Oleg 

12/10/2010
14:08
Avatar
penck
Member
Members
Forum Posts: 6
Member Since:
12/10/2010
sp_UserOfflineSmall Offline

Thanks for your reply ,

in fact , I've tried this, used " jQuery("#productGridView").setGridParam({ datatype: getProducts});" 
to reset the datetype. but it seems that does not work on my computer, server side never receive the 
postback, and the jqgrid just redraw itself , each time, at the bottom , it add the icon for "search" and "refresh", 
maybe there is a conflict of JS ? 

here is my code, could you please check it and tell me where is my problem ?  Thanks a lot  

function getProducts() {            
$.ajax({                
url: "Test.aspx",              
data: jsonData(),                  
dataType: "json",                
type: "POST",                
success: successFunction          
 });        

}

function dataBindToGrid() {

    jQuery("#productGridView").jqGrid({

    datatype: getProducts,

    colNames: ['TestCol1', 'TestCol2', 'TestCol3'],

    colModel: [{ name: 'TestCol1', index: 'TestCol1', width: 200, align: 'left', resizable: true },{ name: 'TestCol2', index: 'TestCol2', width: 200, align: 'left', resizable: true },{ name: 'TestCol3', index: 'TestCol3', width: 200, align: 'left', resizable: true }],

    rowNum: 10,

    autowidth: true,

    rownumbers: true,

    rowList: [5, 10, 20, 50, 100],

    sortname: 'TestCol1',

    pager: jQuery('#pageNavigation'),

    sortorder: "desc",

    viewrecords: true,

    multiselect: true,

    height: 50,

    loadonce: true,

    gridComplete: function () {

           $("#productGridView").setGridParam({ datatype: 'local' });

         }

    });

    jQuery("#productGridView").jqGrid('navGrid','#pageNavigation',  
                               {add:false,edit:false,del:false});

}

jQuery(document).ready(function () {

    jQuery("#testButton1").click(function () {

          jQuery("#productGridView").setGridParam({ datatype: getProducts});

          dataBindToGrid();

});

});

12/10/2010
14:08
Avatar
penck
Member
Members
Forum Posts: 6
Member Since:
12/10/2010
sp_UserOfflineSmall Offline
12/10/2010
14:41
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Which version of the jqGrid you use? Could you post the test JSON data which you receive from the server (you can use Fiddler or Firebug to catch the data).

I would you not recommend to use datatype as function. If was introduced in old versions of jqGrid. Now one should use better parameters like ajaxGridOptions

I find also a little strange, that your server page has extension aspx and not asmx (web service), svc (WCF service) or using ASP.NET MVC with no extension for the URL providing JSON data. Which technology  you use on the server side to produce the JSON output? Wich version of .NET and which version of the Visual Studio you use?

If you gives more information about your server part and the jqGrid version used I'll try to post you some links with the corresponding examples.

Regards
Oleg 

13/10/2010
09:11
Avatar
penck
Member
Members
Forum Posts: 6
Member Since:
12/10/2010
sp_UserOfflineSmall Offline

I use the version 3.8, but maybe my example found from internet is for the old version, I use just a normal web site in Visual Studio , and use json to pass the form data to server , search the data server , and produce the Json data with the function ToJson  , at last , resend the Json to client side by reponse.write :

public string ToJson(ArrayList a, int colNumber)        

{             StringBuilder stringBuilder = new StringBuilder("{");          
 stringBuilder.Append("total: " + SurrondWithQuote(10) + ", ");          
 stringBuilder.Append("page: " + SurrondWithQuote(1) + ", ");          
 stringBuilder.Append("records: " + SurrondWithQuote(1) + ", ");            
stringBuilder.Append("  rows : [ ");          
 for (int i = 0; i < a.Count ; i++)          
 {                
string[] temp = a[i] as string[];                
stringBuilder.Append("{");
  stringBuilder.Append("id:" + SurrondWithQuote(i + 1) + ", ");                
stringBuilder.Append("cell:[ ");              
 for (int j = 0; j < colNumber; j++)                
{                    if (j + 1 != colNumber)                  
 {                        
stringBuilder.Append(SurrondWithQuote(temp[j]) + ", ");                    }                  
 else                       
 stringBuilder.Append(SurrondWithQuote(temp[j]));              
 }                

stringBuilder.Append(" ]");

                if (i == a.Count - 1)              
 {                    stringBuilder.Append(" }");                }              
 else                {                    stringBuilder.Append(" },");                }            
}            
stringBuilder.Append(" ]");          
 stringBuilder.Append(" }");          
 return stringBuilder.ToString();      
 }

 

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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