Author Topic: lazy loading  (Read 574 times)

hirehop

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 43
    • View Profile
lazy loading
« on: June 15, 2023, 02:49:20 pm »
Hello
with greetings of the day

here i have issue with lazy loading while scrolling data some time its failed to load data.
and one more thing is that is possible before load grid or before process  data call another another ajax data will be add in the particular column.

Thank you

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: lazy loading
« Reply #1 on: June 15, 2023, 06:39:03 pm »
Hello hirehop

1. Could you please share a high resolution image. Is it affecting the loading of data in grid.

2. There is no easy solution for it ( loading a column data differently from other columns ) since in lazy loading, remote rows replace the empty rows in dataModel. If this feature is important for you then please post it in suggest new features.

hirehop

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: lazy loading
« Reply #2 on: June 15, 2023, 07:08:14 pm »
here i have sent you high resolution image

hirehop

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: lazy loading
« Reply #3 on: June 15, 2023, 08:51:19 pm »
Regarding my ajax question:

In my example, every one of my rows has a unique ID column.  As pqgrid uses an array and not an indexed JS object, I can't update a specific row column value unless I loop through all the rows, find the matching ID column and update the necessary column, then send the row back to PQGrid.

PQGrid data is an indexed standard array, it would be a solution if it could also be an associative array or if I could load and update the row by passing the unique ID column value and use the ID as a key/index.

My only solution so far is get the array from pqgrid, loop the array to find the required ID, update the necessary column in the row and then send pqGrid the updated row, which is messy and slow.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: lazy loading
« Reply #4 on: June 16, 2023, 01:24:55 pm »
Regarding the error, please ensure to return the data in correct format from the server:

Code: [Select]
{"totalRecords":8618,"curPage":12,"data":[{"id":111,"athlete":"Zou Kai","age":24,"country":"China","year":"2012","date":"2012-08-12","sport":"Gymnastics","gold":2,"silver":0,"bronze":1,"total":3},{"id":112,"athlete":"Cheng Fei","age":20,"country":"China","year":"2008","date":"2008-08-24","sport":"Gymnastics","gold":1,"silver":0,"bronze":2,"total":3},{"id":113,"athlete":"Yang Wei","age":28,"country":"China","year":"2008","date":"2008-08-24","sport":"Gymnastics","gold":2,"silver":1,"bronze":0,"total":3},{"id":114,"athlete":"Yang Yilin","age":15,"country":"China","year":"2008","date":"2008-08-24","sport":"Gymnastics","gold":1,"silver":0,"bronze":2,"total":3},{"id":115,"athlete":"Zou Kai","age":20,"country":"China","year":"2008","date":"2008-08-24","sport":"Gymnastics","gold":3,"silver":0,"bronze":0,"total":3},{"id":116,"athlete":"Marian Dragulescu","age":23,"country":"Romania","year":"2004","date":"2004-08-29","sport":"Gymnastics","gold":0,"silver":1,"bronze":2,"total":3},{"id":117,"athlete":"Paul Hamm","age":21,"country":"United States","year":"2004","date":"2004-08-29","sport":"Gymnastics","gold":1,"silver":2,"bronze":0,"total":3},{"id":118,"athlete":"Carly Patterson","age":16,"country":"United States","year":"2004","date":"2004-08-29","sport":"Gymnastics","gold":1,"silver":2,"bronze":0,"total":3},{"id":119,"athlete":"Catalina Ponor","age":16,"country":"Romania","year":"2004","date":"2004-08-29","sport":"Gymnastics","gold":3,"silver":0,"bronze":0,"total":3},{"id":120,"athlete":"Simona Amânar","age":20,"country":"Romania","year":"2000","date":"2000-10-01","sport":"Gymnastics","gold":2,"silver":0,"bronze":1,"total":3}]}

Required format from the server is also mentioned here: https://paramquery.com/pro/demos/paging

Please share a jsfiddle if still facing error.


2) Sorry, your ajax question is not clear in the context of lazy loading. Why would you require a separate ajax call to update a column value. Why not update it in the intial response from the server itself. It might be helpful to understand your question better if you share some relevant code.
« Last Edit: June 16, 2023, 01:41:17 pm by paramvir »

hirehop

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: lazy loading
« Reply #5 on: June 19, 2023, 04:09:14 pm »
1) Regarding error right almost issue was solve afterwards if any thing is there i will let you know .
2) Regarding ajax
 if we call data with initial response its will take time while loading because of data response delay we have to use ajax data.

   

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: lazy loading
« Reply #6 on: June 20, 2023, 05:42:34 pm »
Quote
My only solution so far is get the array from pqgrid, loop the array to find the required ID, update the necessary column in the row and then send pqGrid the updated row, which is messy and slow.

This logic can be optimized by storing id values and rowData in a plainobject.

Code: [Select]
const rows = [
  { id: 1, name: 'John', age: 25 },
  { id: 2, name: 'Jane', age: 30 },
  { id: 3, name: 'Alex', age: 35 }
];

const convertedObject = rows.reduce((obj, row) => {
  obj[row.id] = row;
  return obj;
}, {});

console.log(convertedObject);

{
  '1': { id: 1, name: 'John', age: 25 },
  '2': { id: 2, name: 'Jane', age: 30 },
  '3': { id: 3, name: 'Alex', age: 35 }
}

I'm not sure what you mean by sending pqGrid the updated row but updating the field value is sufficient if refresh of view of grid is pending:

Code: [Select]
rowData[ dataIndx ] = new value;

hirehop

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: lazy loading
« Reply #7 on: June 20, 2023, 06:27:43 pm »
thank you 
i will check this one

some more issues
1) sort-model : when select whole-cell in sort model for sort column there is filter row also work same problem is that when click on filter its sort the column
2) is it possible to make particular column sort ASC or Desc by default
3) halign also same with filter row  if hlign set center filter textbox or dropdown also set in center
4) how can we change language of grid like  in summary its display like  sum: £45.00 or  count: 5   so i wanted to change language of the word which is display in the grid


Thank you 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: lazy loading
« Reply #8 on: June 20, 2023, 06:55:17 pm »
Could you please create separate posts for different questions.

Thank you