GridJs için sözdizimi denetimi ve yazım düzeltmesi
Contents
[
Hide
]
Kullanıcı girişi üzerinde sözdizimi denetimi ve yazım düzeltmesi yapmak için adımlar
Yükleme seçeneklerini ayarla.
örneğin:
const option = {
...
//set showCheckSyntaxButton to true
showCheckSyntaxButton:true,
//set checkSyntax to true
checkSyntax:true,
};
xs = x_spreadsheet('#gridjs-demo', option)
Sözdizimi denetimi ve yazım düzeltmesi için işlem URL’sini ayarla.
örneğin:
const checkurl = "/GridJs2/CheckSyntax";
xs.setSyntaxCheckUrl(checkurl);
Kullanıcı bir hücreye metin girdikten sonra, sözdizimi denetimi işlemi otomatik olarak elektronik tablo uygulaması tarafından tetiklenir.
Sunucu tarafında sözdizimi denetimi ve yazım düzeltmesi API’sini uygula.
örneğin:
[HttpPost]
public async Task<IActionResult> CheckSyntaxAsync()
{ //the input text content
String text = HttpContext.Request.Form["v"];
/* the locale info : support multiple language for menus ,the locale can be:
en, zh, es, pt, de, ru, nl,
for English,Chinese,Spanish,Portuguese,German,Russian,Dutch
ar, fr,id,it,ja
for Arabic,French,Indonesian,Italian,Japanese
ko,th,tr,vi,cht
for Korean,Thai,Turkey,Vietnamese,Traditional Chinese
*/
String locale = HttpContext.Request.Form["locale"];
if (string.IsNullOrEmpty(text))
{
return Ok(new
{
Success = false,
v = ""
});
}
// The logic for invoking syntax checking here can be implemented through a third-party library or custom logic.
string correctedContent = await CorrectSyntaxAsync(text, locale);
return Ok(new
{
Success = true,
v = correctedContent
});
}
//you need to implement it youself
private async Task<string> CorrectSyntaxAsync(string text,string locale)
{ String result=null;
//your logic to do syntax checking
return result;
}
Daha fazlasını github demo sayfamızda bulabilirsiniz https://github.com/aspose-cells/Aspose.Cells-for-.NET/blob/master/Examples_GridJs/wwwroot/xspread/index.html