List data display method and processing terminal
Through virtualized list and dynamic data loading technology, it solves the problems of high memory usage and slow interface response caused by large amounts of data display in the software, achieving high performance and smooth user experience.
Patent Information
- Application Number
- CN202410872323.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-24
AI Technical Summary
In software development and software applications, when processing large amounts of data through list controls, existing technology can easily lead to excessive memory usage, resulting in slow or unresponsive software interface responses.
Adopt a data display method based on virtualized lists, dynamically load and unload data items, and combine preset cache areas and asynchronous concurrent loading technology to adapt the data volume to the size of the view window, and use the ItemsRepeater control in the Avalonia framework to create virtual List, dynamically render or destroy data items, and optimize scroll event handling.
It effectively reduces memory usage and improves rendering speed, ensuring that users will not encounter lags or delays when browsing long lists, providing higher performance and a smoother user experience.
Smart Images

Figure CN118689366A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computers, and in particular to a list data display method and a processing terminal. Background Art
[0002] In the process of software development and software application, it is often necessary to display a large amount of data, which is a common requirement. Large amounts of data are usually displayed through lists. Excel spreadsheet documents are commonly used to display large amounts of data, or list controls are used to present list views to scroll and display large amounts of data. When processing large amounts of data through list controls, if the display method is not reasonable enough, it is easy to affect software performance due to factors such as excessive memory usage, and it is easy for the software interface where the list control is located to respond slowly or even fail to respond. Therefore, a more efficient list data display method that can realize the display of large amounts of data is needed to improve the performance and user experience of the software (application). Summary of the invention
[0003] In view of the deficiencies of the prior art, an object of the present invention is to provide a list data display method and a processing terminal, which can solve the problems described in the background technology.
[0004] The technical solution for achieving the purpose of the present invention is: a table data display method, comprising the following steps: A list control based on the data to be displayed, the list control including a virtualized list; In response to a scroll start instruction, the virtual list is controlled to scroll along a preset scroll direction in the list display area; in response to a scroll end instruction, the virtual list is controlled to stay in a current area of the list display area, where the current area is a view window for displaying the data to be displayed; Based on the current view window, a data amount of the data to be displayed that is adapted to the size of the view window is loaded, and all the loaded data to be displayed is rendered to the view window.
[0005] Furthermore, it also includes pre-establishing a list control template selector, and in response to a selection operation instruction issued by a user operation or based on a determination of the type of data to be displayed, the list control template selector provides a list control adapted to the type of data to be displayed.
[0006] Furthermore, the list control includes text type, image type and video type list controls, and the list control template selector provides a list control adapted to the type of data to be displayed.
[0007] Furthermore, the specific implementation process of loading the amount of data to be displayed that is adapted to the size of the view window includes the following steps: Based on the current view window size, the width and height of the visible area of the current view window are calculated in pixels. Divide the data to be displayed into several data items in order, and calculate the width and height of each data item by pixel. The number of loaded data items is determined according to the ratio of the width of the visible area to the width of the data item, or the ratio of the height of the visible area to the height of the data item, thereby determining the data volume of the data to be displayed.
[0008] Furthermore, if the current area is a non-visible area, loading of the data to be displayed is prohibited, and the memory occupied by the data to be displayed is released, and then the processing ends.
[0009] Furthermore, the list data display method is implemented based on the Avalonia framework, the list control is an ItemsRepeater control, and the ItemsRepeater control establishes the virtualized list.
[0010] Furthermore, the ItemsRepeater control establishes the virtualized list, including the following steps: Configure the ItemsSource and ItemTemplate properties of the ItemsRepeater control. Create a custom panel, which is used to manage the layout and virtualization of sub-items in the ItemsRepeater control, determine the current scroll position according to the scroll end instruction, calculate the current area, and dynamically render or destroy data items. Create a scroll container, load the ItemsRepeater control into the scroll container, and add a scroll event handler to the scroll container so that the scroll event handler can trigger data loading and unloading operations when the user scrolls.
[0011] Furthermore, before loading the amount of data to be displayed that matches the size of the view window, the method further includes pre-loading the data to be displayed and rendering the pre-loaded data to be displayed to the view window.
[0012] Further, preloading the data to be displayed includes the following steps: A plurality of cache areas with preset data storage amounts are set, each of which stores data to be displayed, and the amount of the stored data to be displayed is the preset storable data amount. Each cache area stores different data to be displayed, and the preset storable data amount is a times the amount of data that can be displayed in the visible area, a>0. If the distance between the current area and the top or bottom of the virtual list is less than or equal to the preset threshold b, the data in the next cache area is preloaded, and the preset threshold b is less than the height of the visible area.
[0013] A processing terminal, comprising: A memory for storing program instructions; The processor is used to run the program instructions to execute the steps of the list data display method.
[0014] Beneficial effects of the present invention: The present invention adopts dynamic data virtualization technology and a scroll view architecture based on performance optimization, which can maintain high performance and smooth user experience when processing large data sets. Compared with traditional list views, the present invention can effectively reduce memory usage and increase rendering speed, ensuring that users will not encounter freezes or delays when browsing long lists, and has higher performance and smoother user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a schematic diagram of the process of the present invention; Figure 2 A schematic diagram of the structure of the processing terminal. DETAILED DESCRIPTION
[0016] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments: like Figure 1 As shown, a list data display method comprises the following steps: Step 1: Create a list control based on the data to be displayed, where the list control includes a virtualized list.
[0017] The list control is used to display the data to be displayed rendered on the list control in a visual form. The data to be displayed can be pre-stored in a database, and the database can store multiple data records, each of which can include data of multiple fields, which constitute the data to be displayed.
[0018] In an optional embodiment, a list control template selector is pre-established, and in response to a selection operation instruction of a user on the list control template selector, or a selection operation instruction issued based on a judgment of the type of data to be displayed, the list control template selector provides a list control that is compatible with the type of data to be displayed. List controls include text type, image type, and video type list controls. When the type of data to be displayed is text, a text type list control is provided, for example, a TextBlock text control is provided, which can be used to display text data, such as character data such as messages, comments, or descriptions. When the type of display data is an image, an image type list control is provided, for example, an Image image control is provided, which can display image data such as pictures, charts, or photos. When the type of data to be displayed is a video, a video type list control is provided, for example, a MediaPlayerElement video control is provided, which can display video data such as video clips, animations, or other multimedia content.
[0019] Step 2: In response to a scroll start instruction, control the virtual list to scroll in the list display area along a preset scroll direction; in response to a scroll end instruction, control the virtual list to stay in the current area of the list display area, where the current area is a view window for displaying the data to be displayed.
[0020] In the initial state, the size of the current area of the virtual list in the list display area is controlled to be fixed, that is, the default view window size is a preset value. For example, in the initial state, the size of the view window just displays two lines of data (text or pictures).
[0021] Step 3: Based on the current view window, load the amount of data to be displayed that is compatible with the view window size, and render all the loaded data to be displayed to the view window, display the data to be displayed in a list, realize data view visualization, and complete list data display.
[0022] The data to be displayed is first loaded into the memory, and then rendered into the view window of the list control, so that the data to be displayed is converted into visual elements and bound to the list control, so that it can be adaptively displayed on the list control.
[0023] Each time the user performs a scrolling operation, the data to be displayed needs to be reloaded according to the latest view window after the current scrolling operation, and the amount of data loaded is adapted to the size of the latest view window, so that the displayed data can be updated by dynamically loading data to follow the list scrolling.
[0024] In an optional implementation, the specific implementation process of loading the amount of data to be displayed that is adapted to the size of the view window includes the following steps: Based on the current view window size, calculate the width and height of the visible area of the current view window in pixels.
[0025] The data to be displayed is divided into several data items in sequence, and the width and height of each data item are calculated by pixel.
[0026] The number of loaded data items is determined according to the ratio of the width of the visible area to the width of the data item, or the ratio of the height of the visible area to the height of the data item, thereby determining the data volume of the data to be displayed.
[0027] For example, if the height of the visible area is 600 pixels and the height of each data item is 50 pixels, 600 / 50=12 data items can be loaded, that is, the amount of data to be displayed is 12 data items. Each data item includes a number of data (characters or graphics).
[0028] In an optional embodiment, in step 2, if the current area is a non-visible area, that is, the scrolling operation slides out of the visible area within the virtual list range, loading of the data to be displayed is prohibited, and the memory occupied by the data to be displayed is released, and then the processing is terminated, that is, step 3 is not executed.
[0029] For example, when the user scrolls up or down and leaves the visible area of the virtual list, the memory needs to be released to maintain efficient memory usage.
[0030] In an optional implementation, the list data display method is implemented based on the Avalonia framework, and the list control is an ItemsRepeater control. The ItemsRepeater control can realize efficient virtualization of long lists.
[0031] To create a virtual list in the ItemsRepeater control, you need to follow these steps: Configure the ItemsSource and ItemTemplate properties of the ItemsRepeater control. For example, you can set the ItemsSource by binding the data to be displayed in the view model, thereby determining the data source of the data to be displayed by the ItemsRepeater control. You can set the ItemTemplate through the template selector.
[0032] The view model is responsible for managing and binding the data to be displayed. It can use collection classes to manage data and provide data binding support. The view model needs to implement data loading, updating, and unloading functions, as well as interaction with the data source. For example, the view model can use ObservableCollection to manage data items and implement the INotifyPropertyChanged interface to notify the UI to update when the data items change.
[0033] Create a custom panel, for example, create VirtualizingStackPanel as a custom panel. The custom panel is used to manage the layout and virtualization of sub-items in the ItemsRepeater control, determine the current scroll position according to the scroll end instruction, calculate the current area, and dynamically render or destroy data items.
[0034] Create a scroll container, such as a ScrollViewer container as the scroll container, and load the ItemsRepeater control into the scroll container to implement the scrolling function. Add a scroll event handler in the scroll container to trigger data loading and unloading operations when the user scrolls.
[0035] In an optional embodiment, in step 3, before loading the amount of data to be displayed that is adapted to the size of the view window, it also includes pre-loading the data to be displayed and rendering the pre-loaded data to be displayed to the view window.
[0036] The pre-loading of the data to be displayed includes the following steps: A plurality of cache areas with preset storable data volumes are set, each of which stores data to be displayed, and the amount of data stored in the data to be displayed is the preset storable data volume, and each cache area stores different data to be displayed. The preset storable data volume is a times the amount of data that can be displayed in the visible area, a>0. For example, assuming that the height of the visible area is 800 pixels and the height of the data item is 50 pixels, the amount of data that can be displayed in the visible area is 800 / 50=16, and the preset storable data volume of the cache area is 16 data items.
[0037] If the distance between the current area and the top or bottom of the virtual list is less than or equal to the preset threshold b, the data in the next cache area is preloaded, that is, the data to be displayed in the cache area is loaded into the memory. The preset threshold b is less than the height of the visible area. For example, if the height of the visible area is 800 pixels and the preset threshold b = 200 pixels, when scrolling to the position 200 pixels from the bottom, the data to be displayed in the next cache area is loaded, thereby achieving preloading.
[0038] In an optional implementation, the data to be displayed is loaded asynchronously and / or concurrently to avoid blocking the UI thread of the interface where the list control is located and to improve loading efficiency. The data to be displayed is loaded concurrently in multiple threads by using a thread pool or parallel programming technology.
[0039] In an optional implementation, the loaded data to be displayed that needs to be rendered is rendered in segments, with a portion of the data to be displayed being rendered each time.
[0040] If the current area can display 1000 data items, it is necessary to load and after the 1000 data items are loaded, divide the 1000 data items into 10 rendering segments, each rendering segment includes 100 data items, and then render each rendering segment in sequence.
[0041] And each time in response to the user's scrolling end operation instruction, the number of rendering segments that need to be divided and the rendering segment that currently needs to be rendered will be re-determined, thereby realizing dynamic segmented rendering to ensure that the data items of the current area are loaded in time.
[0042] The present invention uses dynamic data virtualization technology and a scroll view architecture based on performance optimization to maintain high performance and smooth user experience when processing large data sets. Compared with traditional list views, the present invention can effectively reduce memory usage and increase rendering speed, ensuring that users will not encounter freezes or delays when browsing long lists, with higher performance and smoother user experience.
[0043] like Figure 2 As shown, the present invention also provides a processing terminal 100, which includes: Memory 101, used for storing program instructions; The processor 102 is used to run the program instructions to execute the steps of the list data display method.
[0044] The embodiment disclosed in this specification is only an example of a unilateral feature of the present invention, and the protection scope of the present invention is not limited to this embodiment, and any other functionally equivalent embodiments fall within the protection scope of the present invention. For those skilled in the art, various other corresponding changes and deformations can be made according to the technical solutions and concepts described above, and all of these changes and deformations should fall within the protection scope of the claims of the present invention.
Claims
1. A method for displaying list data, characterized in that: The following steps are involved: A list control based on the data to be displayed, the list control including a virtualized list; In response to a scroll start instruction, the virtual list is controlled to scroll along a preset scroll direction in the list display area; in response to a scroll end instruction, the virtual list is controlled to stay in a current area of the list display area, where the current area is a view window for displaying the data to be displayed; Based on the current view window, a data amount of the data to be displayed that is adapted to the size of the view window is loaded, and all the loaded data to be displayed is rendered to the view window.
2. The list data display method according to claim 1, characterized in that: It also includes pre-establishing a list control template selector, which responds to a selection operation instruction issued by a user operation or based on a determination of the type of data to be displayed, and provides a list control adapted to the type of data to be displayed.
3. The list data display method according to claim 2, characterized in that: The list control includes text type, image type and video type list controls, and the list control template selector provides a list control adapted to the type of data to be displayed.
4. The list data display method according to claim 1, characterized in that: The specific implementation process of loading the amount of data to be displayed that is adapted to the size of the view window includes the following steps: Based on the current view window size, the width and height of the visible area of the current view window are calculated in pixels. Divide the data to be displayed into several data items in order, and calculate the width and height of each data item by pixel. The number of loaded data items is determined according to the ratio of the width of the visible area to the width of the data item, or the ratio of the height of the visible area to the height of the data item, thereby determining the data volume of the data to be displayed.
5. The list data display method according to claim 1, characterized in that: If the current area is a non-visible area, the loading of the data to be displayed is prohibited, and the memory occupied by the data to be displayed is released, and then the processing ends.
6. The list data display method according to claim 1, characterized in that: The list data display method is implemented based on the Avalonia framework, the list control is an ItemsRepeater control, and the ItemsRepeater control establishes the virtualized list.
7. The list data display method according to claim 6, characterized in that: The ItemsRepeater control creates the virtualized list. The following steps are involved: Configure the ItemsSource and ItemTemplate properties of the ItemsRepeater control. Create a custom panel, which is used to manage the layout and virtualization of sub-items in the ItemsRepeater control, determine the current scroll position according to the scroll end instruction, calculate the current area, and dynamically render or destroy data items. Create a scroll container, load the ItemsRepeater control into the scroll container, and add a scroll event handler to the scroll container so that the scroll event handler can trigger data loading and unloading operations when the user scrolls.
8. The list data display method according to claim 1, characterized in that: Before loading the amount of data to be displayed that matches the size of the viewing window, the method further includes pre-loading the data to be displayed and rendering the pre-loaded data to be displayed to the viewing window.
9. The list data display method according to claim 8, characterized in that: Preloading the data to be displayed includes the following steps: A plurality of cache areas with preset data storage amounts are set, each of which stores data to be displayed, and the amount of the stored data to be displayed is the preset storable data amount. Each cache area stores different data to be displayed, and the preset storable data amount is a times the amount of data that can be displayed in the visible area, a>0. If the distance between the current area and the top or bottom of the virtual list is less than or equal to the preset threshold b, the data in the next cache area is preloaded, and the preset threshold b is less than the height of the visible area.
10. A processing terminal, characterized in that: It includes: A memory for storing program instructions; A processor is used to run the program instructions to execute the steps of the list data display method as described in any one of claims 1-9.
