Skip to content

Пример модели таблицы #5

Description

@ildar-ceo

Пример модели таблицы

use Runtime.Widget.Label;
use Runtime.Widget.Events.MouseClickEvent;
use Runtime.Widget.Table.RefreshButton;
use Runtime.Widget.Table.RefreshEvent;
use Runtime.Widget.Table.RowButtons;
use Runtime.Widget.Table.RowNumber;
use Runtime.Widget.Table.TableApiProvider;


class ServiceTable extends TableWidget
{
	
	/**
	 * Init widget
	 */
	async void initWidget()
	{
		await parent::initWidget();
		
		this.setDataProvider( new TableApiProvider("app.application") );
		
		this.addField({
			"name": "row_number",
			"component": classof RowNumber,
		});
		this.addField({
			"name": "service_name",
			"component": classof Label,
		});
		this.addField({
			"name": "status",
			"component": classof Label,
		});
		this.addField({
			"name": "replicas",
			"component": classof Label,
		});
		this.addField({
			"name": "row_buttons",
			"component": classof RowButtons,
		});
		
		/* Add refresh button */
		RefreshButton refresh_button = this.addTopButton( new RefreshButton() );
		refresh_button.addEvent( method this.onRefresh );
	}
	
	
	/**
	 * Refresh event
	 */
	async void onRefresh(RefreshEvent event)
	{
	}
	
	
	/**
	 * Row click
	 */
	async void onRowClick(MouseClickEvent event)
	{
	}
	
	
	/**
	 * Row button click
	 */
	async void onRowButtonClick(MouseClickEvent event)
	{
	}
	
}

Роут:

/**
 * Таблица
 */
async void actionIndex()
{
	/* Создание виджета таблицы */
	TableWidget table = this.page_model.addWidget( new TableWidget({ "widget_name": "table" }) );
	table.setPage(route.query.get("page"));
	async table.init();
	
	/* Загрузка данных таблицы */
	async table.loadData();
	
	/* Заголовок таблицы */
	this.page.setTitle("Список элементов");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions